Index: Makefile
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/Makefile,v
retrieving revision 1.38
diff -u -r1.38 Makefile
--- Makefile	12 Oct 2005 08:07:36 -0000	1.38
+++ Makefile	2 Dec 2005 10:07:39 -0000
@@ -14,11 +14,11 @@
 
 # You should have received a copy of the GNU General Public License
 # along with XEmacs; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
+# the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA  02110-1301  USA
 
 VERSION = 1.30
-AUTHOR_VERSION = 10.2
+AUTHOR_VERSION = 10.6
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = apel
 PKG_TYPE = regular
@@ -32,12 +32,13 @@
 	mcs-20.elc mcs-ltn1.elc mule-caesar.elc path-util.elc \
 	pccl.elc poe-xemacs.elc poe.elc poem-ltn1.elc poem-xm.elc \
 	poem.elc product.elc pym.elc richtext.elc static.elc \
-	pcustom.elc pces.elc pces-raw.elc pces-20.elc pces-xfc.elc
+	pcustom.elc pces.elc pces-raw.elc pces-20.elc pces-xfc.elc \
+	atype.elc file-detect.elc
 
-## The following files are no longer in net apel, but tm needs them.
-ELCS += std11.elc std11-parse.elc file-detect.elc atype.elc
+## The following files are no longer in upstream apel, but tm needs them.
+ELCS += std11.elc std11-parse.elc
 
-EXTRA_SOURCES = README.en
+EXTRA_SOURCES = README.en ChangeLog.upstream
 
 ifeq ($(BUILD_WITHOUT_MULE),)
 # ELCS += emu-x20.elc
Index: apel-ver.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/apel-ver.el,v
retrieving revision 1.1
diff -u -r1.1 apel-ver.el
--- apel-ver.el	10 Jul 2000 04:41:04 -0000	1.1
+++ apel-ver.el	2 Dec 2005 10:07:39 -0000
@@ -39,8 +39,11 @@
   ;; (product-define "APEL" nil '(9 23))	; comment.
   ;; (product-define "APEL" nil '(10 0))	; Released 24 December 1999
   ;; (product-define "APEL" nil '(10 1))	; Released 20 January 2000
-  (product-define "APEL" nil '(10 2))	; Released 01 March 2000
-  ;; (product-define "APEL" nil '(10 3))
+  ;; (product-define "APEL" nil '(10 2))	; Released 01 March 2000
+  ;; (product-define "APEL" nil '(10 3))	; Released 30 December 2000
+  ;; (product-define "APEL" nil '(10 4))	; Released 04 October 2002
+  ;; (product-define "APEL" nil '(10 5))	; Released 06 June 2003
+  (product-define "APEL" nil '(10 6))		; Released 05 July 2003
   )
 
 (defun apel-version ()
Index: atype.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/atype.el,v
retrieving revision 1.4
diff -u -r1.4 atype.el
--- atype.el	10 Jul 2000 04:41:04 -0000	1.4
+++ atype.el	2 Dec 2005 10:07:39 -0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1994,1995,1996,1997 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id: atype.el,v 1.3 1999/07/26 04:30:10 steveb Exp $
+;; Version: $Id: atype.el,v 6.6 1997/03/10 14:11:23 morioka Exp $
 ;; Keywords: atype
 
 ;; This file is part of APEL (A Portable Emacs Library).
Index: broken.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/broken.el,v
retrieving revision 1.4
diff -u -r1.4 broken.el
--- broken.el	6 Oct 2000 08:33:45 -0000	1.4
+++ broken.el	2 Dec 2005 10:07:39 -0000
@@ -1,4 +1,4 @@
-;;; broken.el --- Emacs broken facility infomation registry.
+;;; broken.el --- Emacs broken facility information registry.
 
 ;; Copyright (C) 1998, 1999 Tanaka Akira <akr@jaist.ac.jp>
 
Index: emu.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/emu.el,v
retrieving revision 1.8
diff -u -r1.8 emu.el
--- emu.el	11 Jul 2002 19:09:31 -0000	1.8
+++ emu.el	2 Dec 2005 10:07:39 -0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Keywords: emulation, compatibility, NEmacs, MULE, Emacs/mule, XEmacs
+;; Keywords: emulation, compatibility, Nemacs, MULE, Emacs/mule, XEmacs
 
 ;; This file is part of emu.
 
@@ -98,7 +98,12 @@
 CHAR can be any multilingual character
 TABLE defaults to the current buffer's category table."
 		(mapconcat (lambda (chr)
-			     (char-to-string (int-char chr)))
+			     (if (integerp chr)
+				 (char-to-string (int-char chr))
+			       (char-to-string chr)))
+			   ;; `char-category-list' returns a list of
+			   ;; characters in XEmacs 21.2.25 and later,
+			   ;; otherwise integers.
 			   (char-category-list character)
 			   ""))
 	      )
@@ -114,11 +119,11 @@
 		(category-set-mnemonics (char-category-set character)))
 	      )
 	     (t ; for MULE 1.* and 2.*
-	      ; (require 'emu-mule)
+	      (require 'emu-mule)
 	      ))
        )
       ((boundp 'NEMACS)
-       ;; for NEmacs and NEpoch
+       ;; for Nemacs and Nepoch
 
        ;; old MULE emulation
        (defconst *noconv*    0)
Index: file-detect.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/file-detect.el,v
retrieving revision 1.4
diff -u -r1.4 file-detect.el
--- file-detect.el	10 Jul 2000 04:41:04 -0000	1.4
+++ file-detect.el	2 Dec 2005 10:07:39 -0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1996,1997 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id: file-detect.el,v 1.3 1999/07/26 04:30:11 steveb Exp $
+;; Version: $Id: file-detect.el,v 7.1 1997/11/08 07:40:52 morioka Exp $
 ;; Keywords: file detection, install, module
 ;; Status: obsoleted
 
Index: filename.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/filename.el,v
retrieving revision 1.3
diff -u -r1.3 filename.el
--- filename.el	10 Jul 2000 04:41:04 -0000	1.3
+++ filename.el	2 Dec 2005 10:07:39 -0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1996,1997 MORIOKA Tomohiko
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id: filename.el,v 1.2 1999/07/23 08:33:23 steveb Exp $
+;; Version: $Id: filename.el,v 2.1 1997/11/06 15:50:53 morioka Exp $
 ;; Keywords: file name, string
 
 ;; This file is part of APEL (A Portable Emacs Library).
@@ -58,18 +58,21 @@
   "Alist list of characters vs. string as replacement.
 List of characters represents characters not allowed as file-name.")
 
-(defvar filename-filters
-  (let ((filters '(filename-special-filter
-		   filename-eliminate-top-low-lines
-		   filename-canonicalize-low-lines
-		   filename-maybe-truncate-by-size
-		   filename-eliminate-bottom-low-lines
-		   )))
-    (if (exec-installed-p "kakasi")
-	(cons 'filename-japanese-to-roman-string filters)
-      filters))
-  "List of functions for file-name filter.")
+(defvar filename-filters nil
+  "List of functions for file-name filter.
 
+Example:
+\(setq filename-filters '\(filename-special-filter
+			 filename-eliminate-top-low-lines
+			 filename-canonicalize-low-lines
+			 filename-maybe-truncate-by-size
+			 filename-eliminate-bottom-low-lines\)\)
+
+Moreover, if you want to convert Japanese filename to roman string by kakasi,
+
+\(if \(exec-installed-p \"kakasi\"\)
+    \(setq file-name-filters
+	  \(append '\(filename-japanese-to-roman-string\) filename-filters\)\)\)")
 
 ;;; @ filters
 ;;;
Index: install.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/install.el,v
retrieving revision 1.5
diff -u -r1.5 install.el
--- install.el	26 Dec 2002 11:05:26 -0000	1.5
+++ install.el	2 Dec 2005 10:07:39 -0000
@@ -1,6 +1,6 @@
 ;;; install.el --- Emacs Lisp package install utility
 
-;; Copyright (C) 1996,1997,1998,1999 Free Software Foundation, Inc.
+;; Copyright (C) 1996,1997,1998,1999,2001 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Created: 1996/08/18
@@ -62,6 +62,7 @@
 	    (if (and (file-exists-p full-path) overwrite)
 		(delete-file full-path))
 	    (copy-file src-file full-path t t)
+	    (set-file-modes full-path install-overwritten-file-modes)
 	    (if move
 		(catch 'tag
 		  (while (and (file-exists-p src-file)
@@ -74,7 +75,8 @@
 	    (princ (format "%s -> %s\n" file dest)))))))
 
 (defun install-files (files src dest &optional move overwrite just-print)
-  (or (file-exists-p dest)
+  (or just-print
+      (file-exists-p dest)
       (make-directory dest t))
   (mapcar
    (function
@@ -86,7 +88,7 @@
 ;;; @@ install Emacs Lisp files
 ;;;
 
-(defun install-elisp-module (module src dest &optional just-print)
+(defun install-elisp-module (module src dest &optional just-print del-elc)
   (let (el-file elc-file)
     (let ((name (symbol-name module)))
       (setq el-file (concat name ".el"))
@@ -100,16 +102,23 @@
 	    (if (file-exists-p full-path)
 		(delete-file full-path))
 	    (copy-file src-file full-path t t)
+	    (set-file-modes full-path install-overwritten-file-modes)
 	    (princ (format "%s -> %s\n" el-file dest)))))
       (setq src-file (expand-file-name elc-file src))
       (if (not (file-exists-p src-file))
-	  nil 
+	  (let ((full-path (expand-file-name elc-file dest)))
+	    (if (and del-elc (file-exists-p full-path))
+		(if just-print
+		    (princ (format "%s -> to be deleted\n" full-path))
+		  (delete-file full-path)
+		  (princ (format "%s -> deleted\n" full-path)))))
 	(if just-print
 	    (princ (format "%s -> %s\n" elc-file dest))
 	  (let ((full-path (expand-file-name elc-file dest)))
             (if (file-exists-p full-path)
                 (delete-file full-path))
 	    (copy-file src-file full-path t t)
+	    (set-file-modes full-path install-overwritten-file-modes)
 	    (catch 'tag
 	      (while (file-exists-p src-file)
 		(condition-case err
@@ -119,13 +128,14 @@
 		  (error (princ (format "%s\n" (nth 1 err)))))))
 	    (princ (format "%s -> %s\n" elc-file dest))))))))
 
-(defun install-elisp-modules (modules src dest &optional just-print)
-  (or (file-exists-p dest)
+(defun install-elisp-modules (modules src dest &optional just-print del-elc)
+  (or just-print
+      (file-exists-p dest)
       (make-directory dest t))
   (mapcar
    (function
     (lambda (module)
-      (install-elisp-module module src dest just-print)))
+      (install-elisp-module module src dest just-print del-elc)))
    modules))
 
 
@@ -136,8 +146,9 @@
 (defvar install-prefix
   (if (or (<= emacs-major-version 18)
 	  (featurep 'xemacs)
-	  (and (boundp 'system-configuration-options) ; 19.29 or later
-	       (string= system-configuration-options "NT"))) ; for Meadow
+	  (featurep 'meadow) ; for Meadow
+	  (and (eq system-type 'windows-nt) ; for NTEmacs
+	       (>= emacs-major-version 20)))
       (expand-file-name "../../.." exec-directory)
     (expand-file-name "../../../.." data-directory)))
 
@@ -156,6 +167,7 @@
   (or (catch 'tag
 	(let ((rest default-load-path)
 	      (regexp (concat "^"
+			      ;; XEmacs change: handle backslashes (Windows)
 			      (regexp-quote (replace-in-string
 					     (file-name-as-directory
 					      (expand-file-name elisp-prefix))
@@ -165,12 +177,14 @@
 			       (replace-in-string prefix "\\\\" "/"))
 			      "/?$")))
 	  (while rest
+	    ;; XEmacs change: handle backslashes (Windows)
 	    (if (string-match regexp
 			      (replace-in-string (car rest) "\\\\" "/"))
 		(if (or allow-version-specific
 			(not (string-match (format "/%d\\.%d"
 						   emacs-major-version
 						   emacs-minor-version)
+					   ;; XEmacs change: handle backslashes
 					   (replace-in-string (car rest)
 							      "\\\\" "/"))))
 		    (throw 'tag (car rest))))
@@ -196,6 +210,50 @@
 
 (defvar install-default-elisp-directory
   (install-detect-elisp-directory))
+
+
+;;; @ for XEmacs package system
+;;;
+
+(defun install-update-package-files (package dir &optional just-print)
+  (cond
+   (just-print
+    (princ (format "Updating autoloads in directory %s..\n\n" dir))
+
+    (princ (format "Processing %s\n" dir))
+    (princ "Generating custom-load.el...\n\n")
+
+    (princ (format "Compiling %s...\n"
+		   (expand-file-name "auto-autoloads.el" dir)))
+    (princ (format "Wrote %s\n"
+		   (expand-file-name "auto-autoloads.elc" dir)))
+
+    (princ (format "Compiling %s...\n"
+		   (expand-file-name "custom-load.el" dir)))
+    (princ (format "Wrote %s\n"
+		   (expand-file-name "custom-load.elc" dir))))
+   (t
+    (setq autoload-package-name package)
+
+    (let ((command-line-args-left (list dir)))
+      (batch-update-directory))
+
+    (let ((command-line-args-left (list dir)))
+      (Custom-make-dependencies))
+
+    (byte-compile-file (expand-file-name "auto-autoloads.el" dir))
+    (byte-compile-file (expand-file-name "custom-load.el" dir)))))
+
+
+;;; @ Other Utilities
+;;;
+
+(defun install-just-print-p ()
+  (let ((flag (getenv "MAKEFLAGS"))
+	(case-fold-search nil))
+    (princ (format "%s\n" flag))
+    (if flag
+	(string-match "^\\(\\(--[^ ]+ \\)+-\\|[^ =-]\\)*n" flag))))
 
 
 ;;; @ end
Index: mcharset.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/mcharset.el,v
retrieving revision 1.3
diff -u -r1.3 mcharset.el
--- mcharset.el	10 Jul 2000 04:41:05 -0000	1.3
+++ mcharset.el	2 Dec 2005 10:07:39 -0000
@@ -1,6 +1,6 @@
 ;;; mcharset.el --- MIME charset API
 
-;; Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
+;; Copyright (C) 1997,1998,1999,2000 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
 ;; Keywords: emulation, compatibility, Mule
@@ -28,28 +28,18 @@
 (require 'pcustom)
 
 (cond ((featurep 'mule)
-       (cond ((featurep 'xemacs)
-	      (require 'mcs-xm)
-	      )
-	     ((>= emacs-major-version 20)
-	      (require 'mcs-e20)
-	      )
-	     (t
-	      ;; for MULE 1.* and 2.*
-	      (require 'mcs-om)
-	      ))
-       )
+       (if (>= emacs-major-version 20)
+	   (require 'mcs-20)
+	 ;; for MULE 1.* and 2.*
+	 (require 'mcs-om)))
       ((boundp 'NEMACS)
        ;; for Nemacs and Nepoch
-       (require 'mcs-nemacs)
-       )
+       (require 'mcs-nemacs))
       (t
-       (require 'mcs-ltn1)
-       ))
+       (require 'mcs-ltn1)))
 
 (defcustom default-mime-charset-for-write
-  (if (and (fboundp 'find-coding-system)
-	   (find-coding-system 'utf-8))
+  (if (mime-charset-p 'utf-8)
       'utf-8
     default-mime-charset)
   "Default value of MIME-charset for encoding.
Index: mcs-20.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/mcs-20.el,v
retrieving revision 1.5
diff -u -r1.5 mcs-20.el
--- mcs-20.el	10 Jul 2000 04:41:05 -0000	1.5
+++ mcs-20.el	2 Dec 2005 10:07:39 -0000
@@ -1,8 +1,8 @@
 ;;; mcs-20.el --- MIME charset implementation for Emacs 20 and XEmacs/mule
 
-;; Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
+;; Copyright (C) 1997,1998,1999,2000 Free Software Foundation, Inc.
 
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
 ;; Keywords: emulation, compatibility, Mule
 
 ;; This file is part of APEL (A Portable Emacs Library).
@@ -29,10 +29,13 @@
 
 ;;; Code:
 
-(require 'poem)
-(require 'pcustom)
+(require 'custom)
 (eval-when-compile (require 'wid-edit))
 
+(if (featurep 'xemacs)
+    (require 'mcs-xm)
+  (require 'mcs-e20))
+
 
 ;;; @ MIME charset
 ;;;
@@ -100,6 +103,8 @@
 		   charset lbt cs)
 	))))
 
+(defalias 'mime-charset-p 'mime-charset-to-coding-system)
+
 (defvar widget-mime-charset-prompt-value-history nil
   "History of input to `widget-mime-charset-prompt-value'.")
 
@@ -132,17 +137,85 @@
     (widget-apply widget :notify widget event)
     (widget-setup)))
 
-(defcustom default-mime-charset 'x-ctext
+(defcustom default-mime-charset 'x-unknown
   "Default value of MIME-charset.
 It is used when MIME-charset is not specified.
 It must be symbol."
   :group 'i18n
   :type 'mime-charset)
 
+(cond ((featurep 'utf-2000)
+;; for CHISE Architecture
+(defun mcs-region-repertoire-p (start end charsets &optional buffer)
+  (save-excursion
+    (if buffer
+	(set-buffer buffer))
+    (save-restriction
+      (narrow-to-region start end)
+      (goto-char (point-min))
+      (catch 'tag
+	(let (ch)
+	  (while (not (eobp))
+	    (setq ch (char-after (point)))
+	    (unless (some (lambda (ccs)
+			    (encode-char ch ccs))
+			  charsets)
+	      (throw 'tag nil))
+	    (forward-char)))
+	t))))
+
+(defun mcs-string-repertoire-p (string charsets &optional start end)
+  (let ((i (if start
+	       (if (< start 0)
+		   (error 'args-out-of-range string start end)
+		 start)
+	     0))
+	ch)
+    (if end
+	(if (> end (length string))
+	    (error 'args-out-of-range string start end))
+      (setq end (length string)))
+    (catch 'tag
+      (while (< i end)
+	(setq ch (aref string i))
+	(unless (some (lambda (ccs)
+			(encode-char ch ccs))
+		      charsets)
+	  (throw 'tag nil))
+	(setq i (1+ i)))
+      t)))
+
+(defun detect-mime-charset-region (start end)
+  "Return MIME charset for region between START and END."
+  (let ((rest charsets-mime-charset-alist)
+	cell)
+    (catch 'tag
+      (while rest
+	(setq cell (car rest))
+	(if (mcs-region-repertoire-p start end (car cell))
+	    (throw 'tag (cdr cell)))
+	(setq rest (cdr rest)))
+      default-mime-charset-for-write)))
+
+(defun detect-mime-charset-string (string)
+  "Return MIME charset for STRING."
+  (let ((rest charsets-mime-charset-alist)
+	cell)
+    (catch 'tag
+      (while rest
+	(setq cell (car rest))
+	(if (mcs-string-repertoire-p string (car cell))
+	    (throw 'tag (cdr cell)))
+	(setq rest (cdr rest)))
+      default-mime-charset-for-write)))
+)
+(t
+;; for legacy Mule
 (defun detect-mime-charset-region (start end)
   "Return MIME charset for region between START and END."
   (find-mime-charset-by-charsets (find-charset-region start end)
 				 'region start end))
+))
 
 (defun write-region-as-mime-charset (charset start end filename
 					     &optional append visit lockname)
Index: mcs-ltn1.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/mcs-ltn1.el,v
retrieving revision 1.2
diff -u -r1.2 mcs-ltn1.el
--- mcs-ltn1.el	10 Jul 2000 04:41:05 -0000	1.2
+++ mcs-ltn1.el	2 Dec 2005 10:07:39 -0000
@@ -1,9 +1,9 @@
 ;;; mcs-ltn1.el --- MIME charset implementation for Emacs 19
 ;;;                 and XEmacs without MULE
 
-;; Copyright (C) 1995,1996,1997,1998 MORIOKA Tomohiko
+;; Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc.
 
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
 ;; Keywords: emulation, compatibility, Mule
 
 ;; This file is part of APEL (A Portable Emacs Library).
@@ -38,13 +38,13 @@
 		   (mac . "\r"))))
   )
 
-(defun mime-charset-to-coding-system (charset)
+(defun mime-charset-to-coding-system (charset &optional lbt)
   (if (stringp charset)
-      (setq charset (intern (downcase charset)))
-    )
+      (setq charset (intern (downcase charset))))
   (if (memq charset (list 'us-ascii default-mime-charset))
-      charset
-    ))
+      charset))
+
+(defalias 'mime-charset-p 'mime-charset-to-coding-system)
 
 (defun detect-mime-charset-region (start end)
   "Return MIME charset for region between START and END."
Index: mcs-xm.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/mcs-xm.el,v
retrieving revision 1.3
diff -u -r1.3 mcs-xm.el
--- mcs-xm.el	14 Jul 2002 03:23:11 -0000	1.3
+++ mcs-xm.el	2 Dec 2005 10:07:39 -0000
@@ -1,9 +1,9 @@
 ;;; mcs-xm.el --- MIME charset implementation for XEmacs-mule
 
-;; Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
+;; Copyright (C) 1997,1998,1999,2000 Free Software Foundation, Inc.
 
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Keywords: emulation, compatibility, Mule
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
+;; Keywords: MIME-charset, coding-system, emulation, compatibility, Mule
 
 ;; This file is part of APEL (A Portable Emacs Library).
 
@@ -29,7 +29,7 @@
 
 ;;; Code:
 
-(require 'mcs-20)
+(require 'poem)
 
 
 (defun encode-mime-charset-region (start end charset &optional lbt)
@@ -103,35 +103,71 @@
 
 
 (defvar charsets-mime-charset-alist
-  '(((ascii)						. us-ascii)
-    ((ascii latin-iso8859-1)				. iso-8859-1)
-    ((ascii latin-iso8859-2)				. iso-8859-2)
-    ((ascii latin-iso8859-3)				. iso-8859-3)
-    ((ascii latin-iso8859-4)				. iso-8859-4)
-    ((ascii cyrillic-iso8859-5)				. iso-8859-5)
-;;; ((ascii cyrillic-iso8859-5)				. koi8-r)
-    ((ascii arabic-iso8859-6)				. iso-8859-6)
-    ((ascii greek-iso8859-7)				. iso-8859-7)
-    ((ascii hebrew-iso8859-8)				. iso-8859-8)
-    ((ascii latin-iso8859-9)				. iso-8859-9)
-    ((ascii latin-jisx0201
-	    japanese-jisx0208-1978 japanese-jisx0208)	. iso-2022-jp)
-    ((ascii latin-jisx0201
-	    katakana-jisx0201 japanese-jisx0208)	. shift_jis)
-    ((ascii korean-ksc5601)				. euc-kr)
-    ((ascii chinese-gb2312)				. gb2312)
-    ((ascii chinese-big5-1 chinese-big5-2)		. big5)
-    ((ascii thai-xtis)					. tis-620)
-    ((ascii latin-iso8859-1 greek-iso8859-7
-	    latin-jisx0201 japanese-jisx0208-1978
-	    chinese-gb2312 japanese-jisx0208
-	    korean-ksc5601 japanese-jisx0212)		. iso-2022-jp-2)
-    ;; ((ascii latin-iso8859-1 greek-iso8859-7
-    ;;         latin-jisx0201 japanese-jisx0208-1978
-    ;;         chinese-gb2312 japanese-jisx0208
-    ;;         korean-ksc5601 japanese-jisx0212
-    ;;         chinese-cns11643-1 chinese-cns11643-2)      . iso-2022-int-1)
-    ))
+  (delq
+   nil
+   `(((ascii)						. us-ascii)
+     ((ascii latin-iso8859-1)				. iso-8859-1)
+     ((ascii latin-iso8859-2)				. iso-8859-2)
+     ((ascii latin-iso8859-3)				. iso-8859-3)
+     ((ascii latin-iso8859-4)				. iso-8859-4)
+     ((ascii cyrillic-iso8859-5)			. iso-8859-5)
+     ;;((ascii cyrillic-iso8859-5)			. koi8-r)
+     ((ascii arabic-iso8859-6)				. iso-8859-6)
+     ((ascii greek-iso8859-7)				. iso-8859-7)
+     ((ascii hebrew-iso8859-8)				. iso-8859-8)
+     ((ascii latin-iso8859-9)				. iso-8859-9)
+     ,(if (find-coding-system 'iso-8859-14)
+	  '((ascii latin-iso8859-14)			. iso-8859-14))
+     ,(if (find-coding-system 'iso-8859-15)
+	  '((ascii latin-iso8859-15)			. iso-8859-15))
+     ,(if (featurep 'utf-2000)
+	  '((ascii latin-jisx0201
+		   japanese-jisx0208-1978
+		   japanese-jisx0208
+		   japanese-jisx0208-1990)		. iso-2022-jp)
+	'((ascii latin-jisx0201
+		 japanese-jisx0208-1978 japanese-jisx0208)
+	  . iso-2022-jp))
+     ,(if (featurep 'utf-2000)
+	  '((ascii latin-jisx0201
+		   japanese-jisx0208-1978
+		   japanese-jisx0208
+		   japanese-jisx0208-1990
+		   japanese-jisx0213-1
+		   japanese-jisx0213-2)			. iso-2022-jp-3)
+	'((ascii latin-jisx0201
+		 japanese-jisx0208-1978 japanese-jisx0208
+		 japanese-jisx0213-1
+		 japanese-jisx0213-2)			. iso-2022-jp-3))
+     ,(if (featurep 'utf-2000)
+	  '((ascii latin-jisx0201 katakana-jisx0201
+		   japanese-jisx0208-1990)		. shift_jis)
+	'((ascii latin-jisx0201
+		 katakana-jisx0201 japanese-jisx0208)	. shift_jis))
+     ((ascii korean-ksc5601)				. euc-kr)
+     ((ascii chinese-gb2312)				. gb2312)
+     ((ascii chinese-big5-1 chinese-big5-2)		. big5)
+     ((ascii thai-xtis)					. tis-620)
+     ,(if (featurep 'utf-2000)
+	  '((ascii latin-jisx0201 latin-iso8859-1
+		   greek-iso8859-7
+		   japanese-jisx0208-1978 japanese-jisx0208
+		   japanese-jisx0208-1990
+		   japanese-jisx0212
+		   chinese-gb2312
+		   korean-ksc5601)		. iso-2022-jp-2)
+	'((ascii latin-jisx0201 latin-iso8859-1
+		 greek-iso8859-7
+		 japanese-jisx0208-1978 japanese-jisx0208
+		 japanese-jisx0212
+		 chinese-gb2312
+		 korean-ksc5601)			. iso-2022-jp-2))
+     ;;((ascii latin-iso8859-1 greek-iso8859-7
+     ;;        latin-jisx0201 japanese-jisx0208-1978
+     ;;        chinese-gb2312 japanese-jisx0208
+     ;;        korean-ksc5601 japanese-jisx0212
+     ;;        chinese-cns11643-1 chinese-cns11643-2)      . iso-2022-int-1)
+     )))
 
 
 (defun coding-system-to-mime-charset (coding-system)
Index: path-util.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/path-util.el,v
retrieving revision 1.4
diff -u -r1.4 path-util.el
--- path-util.el	6 Oct 2000 08:33:45 -0000	1.4
+++ path-util.el	2 Dec 2005 10:07:40 -0000
@@ -54,18 +54,16 @@
 	       (while rest
 		 (setq p (expand-file-name path (car rest)))
 		 (if (file-directory-p p)
-		     (throw 'tag p)
-		   )
-		 (setq rest (cdr rest))
-		 ))
-	     (not (member p load-path))
-	     )
+		     (throw 'tag p))
+		 (setq rest (cdr rest))))
+	     (not (or (member p load-path)
+		      (if (string-match "/$" p)
+			  (member (substring p 0 (1- (length p))) load-path)
+			(member (file-name-as-directory p) load-path)))))
 	(setq load-path
 	      (if (memq 'append options)
 		  (append load-path (list p))
-		(cons p load-path)
-		))
-      )))
+		(cons p load-path))))))
 
 ;;;###autoload
 (defun add-latest-path (pattern &optional all-paths)
Index: pccl-20.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/pccl-20.el,v
retrieving revision 1.2
diff -u -r1.2 pccl-20.el
--- pccl-20.el	10 Jul 2000 04:41:05 -0000	1.2
+++ pccl-20.el	2 Dec 2005 10:07:40 -0000
@@ -48,6 +48,26 @@
 
 (eval-and-compile
 
+  (static-if (featurep 'xemacs)
+      (defadvice make-coding-system (before ccl-compat (name type &rest ad-subr-args) activate)
+	(when (and (integerp type)
+		   (eq type 4)
+		   (characterp (ad-get-arg 2))
+		   (stringp (ad-get-arg 3))
+		   (consp (ad-get-arg 4))
+		   (symbolp (car (ad-get-arg 4)))
+		   (symbolp (cdr (ad-get-arg 4))))
+	  (setq type 'ccl)
+	  (setq ad-subr-args
+		(list
+		 (ad-get-arg 3)
+		 (append
+		  (list
+		   'mnemonic (char-to-string (ad-get-arg 2))
+		   'decode (symbol-value (car (ad-get-arg 4)))
+		   'encode (symbol-value (cdr (ad-get-arg 4))))
+		  (ad-get-arg 5)))))))
+
   (if (featurep 'xemacs)
       (defun make-ccl-coding-system (name mnemonic docstring decoder encoder)
 	"\
Index: pccl.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/pccl.el,v
retrieving revision 1.4
diff -u -r1.4 pccl.el
--- pccl.el	14 May 2002 03:50:10 -0000	1.4
+++ pccl.el	2 Dec 2005 10:07:40 -0000
@@ -34,10 +34,11 @@
          (>= emacs-major-version 19))))
 
 (unless-broken ccl-usable
+  (require 'advice)
+
   (if (featurep 'mule)
       (progn
 	(require 'ccl)
-	(require 'advice)
 	(if (featurep 'xemacs)
             (if (>= emacs-major-version 21)
                 ;; for XEmacs 21 with mule
@@ -48,24 +49,116 @@
             ;; for Mule 2.*
             (require 'pccl-om)))))
 
-  (defadvice define-ccl-program
-    (before accept-long-ccl-program activate)
-    "When CCL-PROGRAM is too long, internal buffer is extended automatically."
-    (let ((try-ccl-compile t)
-          (prog (eval (ad-get-arg 1))))
-      (ad-set-arg 1 (` '(, prog)))
-      (while try-ccl-compile
-        (setq try-ccl-compile nil)
-        (condition-case sig
-            (ccl-compile prog)
-          (args-out-of-range
-           (if (and (eq (car (cdr sig)) ccl-program-vector)
-                    (= (car (cdr (cdr sig))) (length ccl-program-vector)))
-               (setq ccl-program-vector
-                     (make-vector (* 2 (length ccl-program-vector)) 0)
-                     try-ccl-compile t)
-             (signal (car sig) (cdr sig))))))))
-  )
+  (static-if (or (featurep 'xemacs) (< emacs-major-version 21))
+    (defadvice define-ccl-program
+      (before accept-long-ccl-program activate)
+      "When CCL-PROGRAM is too long, internal buffer is extended automatically."
+      (let ((try-ccl-compile t)
+	    (prog (eval (ad-get-arg 1))))
+	(ad-set-arg 1 (` '(, prog)))
+	(while try-ccl-compile
+	  (setq try-ccl-compile nil)
+	  (condition-case sig
+	      (ccl-compile prog)
+	    (args-out-of-range
+	     (if (and (eq (car (cdr sig)) ccl-program-vector)
+		      (= (car (cdr (cdr sig))) (length ccl-program-vector)))
+		 (setq ccl-program-vector
+		       (make-vector (* 2 (length ccl-program-vector)) 0)
+		       try-ccl-compile t)
+	       (signal (car sig) (cdr sig)))))))))
+
+  (static-when (and (not (featurep 'xemacs)) (< emacs-major-version 21))
+    (defun-maybe transform-make-coding-system-args (name type &optional doc-string props)
+      "For internal use only.
+Transform XEmacs style args for `make-coding-system' to Emacs style.
+Value is a list of transformed arguments."
+      (let ((mnemonic (string-to-char (or (plist-get props 'mnemonic) "?")))
+	    (eol-type (plist-get props 'eol-type))
+	    properties tmp)
+	(cond
+	 ((eq eol-type 'lf) (setq eol-type 'unix))
+	 ((eq eol-type 'crlf) (setq eol-type 'dos))
+	 ((eq eol-type 'cr) (setq eol-type 'mac)))
+	(if (setq tmp (plist-get props 'post-read-conversion))
+	    (setq properties (plist-put properties 'post-read-conversion tmp)))
+	(if (setq tmp (plist-get props 'pre-write-conversion))
+	    (setq properties (plist-put properties 'pre-write-conversion tmp)))
+	(cond
+	 ((eq type 'shift-jis)
+	  (` ((, name) 1 (, mnemonic) (, doc-string)
+	      nil (, properties) (, eol-type))))
+	 ((eq type 'iso2022) ; This is not perfect.
+	  (if (plist-get props 'escape-quoted)
+	      (error "escape-quoted is not supported: %S"
+		     (` ((, name) (, type) (, doc-string) (, props)))))
+	  (let ((g0 (plist-get props 'charset-g0))
+		(g1 (plist-get props 'charset-g1))
+		(g2 (plist-get props 'charset-g2))
+		(g3 (plist-get props 'charset-g3))
+		(use-roman
+		 (and
+		  (eq (cadr (assoc 'latin-jisx0201
+				   (plist-get props 'input-charset-conversion)))
+		      'ascii)
+		  (eq (cadr (assoc 'ascii
+				   (plist-get props 'output-charset-conversion)))
+		      'latin-jisx0201)))
+		(use-oldjis
+		 (and
+		  (eq (cadr (assoc 'japanese-jisx0208-1978
+				   (plist-get props 'input-charset-conversion)))
+		      'japanese-jisx0208)
+		  (eq (cadr (assoc 'japanese-jisx0208
+				   (plist-get props 'output-charset-conversion)))
+		      'japanese-jisx0208-1978))))
+	    (if (charsetp g0)
+		(if (plist-get props 'force-g0-on-output)
+		    (setq g0 (` (nil (, g0))))
+		  (setq g0 (` ((, g0) t)))))
+	    (if (charsetp g1)
+		(if (plist-get props 'force-g1-on-output)
+		    (setq g1 (` (nil (, g1))))
+		  (setq g1 (` ((, g1) t)))))
+	    (if (charsetp g2)
+		(if (plist-get props 'force-g2-on-output)
+		    (setq g2 (` (nil (, g2))))
+		  (setq g2 (` ((, g2) t)))))
+	    (if (charsetp g3)
+		(if (plist-get props 'force-g3-on-output)
+		    (setq g3 (` (nil (, g3))))
+		  (setq g3 (` ((, g3) t)))))
+	    (` ((, name) 2 (, mnemonic) (, doc-string)
+		((, g0) (, g1) (, g2) (, g3)
+		 (, (plist-get props 'short))
+		 (, (not (plist-get props 'no-ascii-eol)))
+		 (, (not (plist-get props 'no-ascii-cntl)))
+		 (, (plist-get props 'seven))
+		 t
+		 (, (not (plist-get props 'lock-shift)))
+		 (, use-roman)
+		 (, use-oldjis)
+		 (, (plist-get props 'no-iso6429))
+		 nil nil nil nil)
+		(, properties) (, eol-type)))))
+	 ((eq type 'big5)
+	  (` ((, name) 3 (, mnemonic) (, doc-string)
+	      nil (, properties) (, eol-type))))
+	 ((eq type 'ccl)
+	  (` ((, name) 4 (, mnemonic) (, doc-string)
+	      ((, (plist-get props 'decode)) . (, (plist-get props 'encode)))
+	      (, properties) (, eol-type))))
+	 (t
+	  (error "unsupported XEmacs style make-coding-style arguments: %S"
+		 (` ((, name) (, type) (, doc-string) (, props))))))))
+    (defadvice make-coding-system
+      (before ccl-compat (name type &rest ad-subr-args) activate)
+      "Emulate XEmacs style make-coding-system."
+      (when (and (symbolp type) (not (memq type '(t nil))))
+        (let ((args (apply 'transform-make-coding-system-args
+	                   name type ad-subr-args)))
+	  (setq type (cadr args)
+	        ad-subr-args (cddr args)))))))
 
 
 ;;; @ end
Index: poe.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/poe.el,v
retrieving revision 1.6
diff -u -r1.6 poe.el
--- poe.el	26 Jun 2005 19:17:09 -0000	1.6
+++ poe.el	2 Dec 2005 10:07:40 -0000
@@ -75,7 +75,6 @@
    (or (fboundp 'si:require)
        (progn
 	 (fset 'si:require (symbol-function 'require))
-	 (put 'require 'defun-maybe t)
 	 (defun require (feature &optional filename noerror)
 	   "\
 If feature FEATURE is not loaded, load it from FILENAME.
@@ -90,7 +89,10 @@
 	       (condition-case nil
 		   (si:require feature filename)
 		 (file-error))
-	     (si:require feature filename)))))))
+	     (si:require feature filename)))
+	 ;; for `load-history'.
+	 (setq current-load-list (cons 'require current-load-list))
+	 (put 'require 'defun-maybe t)))))
 
 ;; Emacs 19.29 and later: (plist-get PLIST PROP)
 ;; (defun-maybe plist-get (plist prop)
@@ -265,7 +267,7 @@
 DEF, if non-nil, is the default value.
 
 Completion ignores case if the ambient value of
-  `completion-ignore-case' is non-nil."  
+  `completion-ignore-case' is non-nil."
 	(let ((string (si:completing-read prompt table predicate
 					  require-match init hist)))
 	  (if (and (string= string "") def)
@@ -290,7 +292,7 @@
 	 (if (fboundp 'string-to-number)
 	     (fset 'si:string-to-number (symbol-function 'string-to-number))
 	   (fset 'si:string-to-number (symbol-function 'string-to-int))
-	   ;; XXX: In v18, this causes infinite loop while bytecompiling.
+	   ;; XXX: In v18, this causes infinite loop while byte-compiling.
 	   ;; (defalias 'string-to-int 'string-to-number)
 	   )
 	 (put 'string-to-number 'defun-maybe t)
@@ -702,49 +704,97 @@
 	     (throw 'found (car list))))
       (setq list (cdr list)))))
 
-;; XEmacs 19.13 and later: (remassq KEY LIST)
-(defun-maybe remassq (key list)
-  "Delete by side effect any elements of LIST whose car is `eq' to KEY.
-The modified LIST is returned.  If the first member of LIST has a car
-that is `eq' to KEY, there is no way to remove it by side effect;
-therefore, write `(setq foo (remassq key foo))' to be sure of changing
-the value of `foo'."
-  (if (setq key (assq key list))
-      (delq key list)
-    list))
-
-;; XEmacs 19.13 and later: (remassoc KEY LIST)
-(defun-maybe remassoc (key list)
-  "Delete by side effect any elements of LIST whose car is `equal' to KEY.
-The modified LIST is returned.  If the first member of LIST has a car
+;; XEmacs 19.13 and later: (remassoc KEY ALIST)
+(defun-maybe remassoc (key alist)
+  "Delete by side effect any elements of ALIST whose car is `equal' to KEY.
+The modified ALIST is returned.  If the first member of ALIST has a car
 that is `equal' to KEY, there is no way to remove it by side effect;
 therefore, write `(setq foo (remassoc key foo))' to be sure of changing
 the value of `foo'."
-  (if (setq key (assoc key list))
-      (delq key list)
-    list))
-
-;; XEmacs 19.13 and later: (remrassq VALUE LIST)
-(defun-maybe remrassq (value list)
-  "Delete by side effect any elements of LIST whose cdr is `eq' to VALUE.
-The modified LIST is returned.  If the first member of LIST has a car
-that is `eq' to VALUE, there is no way to remove it by side effect;
-therefore, write `(setq foo (remrassq value foo))' to be sure of changing
+  (while (and (consp alist)
+              (or (not (consp (car alist)))
+                  (equal (car (car alist)) key)))
+    (setq alist (cdr alist)))
+  (if (consp alist)
+      (let ((prev alist)
+            (tail (cdr alist)))
+        (while (consp tail)
+          (if (and (consp (car alist))
+                   (equal (car (car tail)) key))
+              ;; `(setcdr CELL NEWCDR)' returns NEWCDR.
+              (setq tail (setcdr prev (cdr tail)))
+            (setq prev (cdr prev)
+                  tail (cdr tail))))))
+  alist)
+
+;; XEmacs 19.13 and later: (remassq KEY ALIST)
+(defun-maybe remassq (key alist)
+  "Delete by side effect any elements of ALIST whose car is `eq' to KEY.
+The modified ALIST is returned.  If the first member of ALIST has a car
+that is `eq' to KEY, there is no way to remove it by side effect;
+therefore, write `(setq foo (remassq key foo))' to be sure of changing
 the value of `foo'."
-  (if (setq value (rassq value list))
-      (delq value list)
-    list))
-
-;; XEmacs 19.13 and later: (remrassoc VALUE LIST)
-(defun-maybe remrassoc (value list)
-  "Delete by side effect any elements of LIST whose cdr is `equal' to VALUE.
-The modified LIST is returned.  If the first member of LIST has a car
+  (while (and (consp alist)
+              (or (not (consp (car alist)))
+                  (eq (car (car alist)) key)))
+    (setq alist (cdr alist)))
+  (if (consp alist)
+      (let ((prev alist)
+            (tail (cdr alist)))
+        (while (consp tail)
+          (if (and (consp (car tail))
+                   (eq (car (car tail)) key))
+              ;; `(setcdr CELL NEWCDR)' returns NEWCDR.
+              (setq tail (setcdr prev (cdr tail)))
+            (setq prev (cdr prev)
+                  tail (cdr tail))))))
+  alist)
+
+;; XEmacs 19.13 and later: (remrassoc VALUE ALIST)
+(defun-maybe remrassoc (value alist)
+  "Delete by side effect any elements of ALIST whose cdr is `equal' to VALUE.
+The modified ALIST is returned.  If the first member of ALIST has a car
 that is `equal' to VALUE, there is no way to remove it by side effect;
 therefore, write `(setq foo (remrassoc value foo))' to be sure of changing
 the value of `foo'."
-  (if (setq value (rassoc value list))
-      (delq value list)
-    list))
+  (while (and (consp alist)
+              (or (not (consp (car alist)))
+                  (equal (cdr (car alist)) value)))
+    (setq alist (cdr alist)))
+  (if (consp alist)
+      (let ((prev alist)
+            (tail (cdr alist)))
+        (while (consp tail)
+          (if (and (consp (car tail))
+                   (equal (cdr (car tail)) value))
+              ;; `(setcdr CELL NEWCDR)' returns NEWCDR.
+              (setq tail (setcdr prev (cdr tail)))
+            (setq prev (cdr prev)
+                  tail (cdr tail))))))
+  alist)
+
+;; XEmacs 19.13 and later: (remrassq VALUE ALIST)
+(defun-maybe remrassq (value alist)
+  "Delete by side effect any elements of ALIST whose cdr is `eq' to VALUE.
+The modified ALIST is returned.  If the first member of ALIST has a car
+that is `eq' to VALUE, there is no way to remove it by side effect;
+therefore, write `(setq foo (remrassq value foo))' to be sure of changing
+the value of `foo'."
+  (while (and (consp alist)
+              (or (not (consp (car alist)))
+                  (eq (cdr (car alist)) value)))
+    (setq alist (cdr alist)))
+  (if (consp alist)
+      (let ((prev alist)
+            (tail (cdr alist)))
+        (while (consp tail)
+          (if (and (consp (car tail))
+                   (eq (cdr (car tail)) value))
+              ;; `(setcdr CELL NEWCDR)' returns NEWCDR.
+              (setq tail (setcdr prev (cdr tail)))
+            (setq prev (cdr prev)
+                  tail (cdr tail))))))
+  alist)
 
 ;;; Define `functionp' here because "localhook" uses it.
 
@@ -847,6 +897,11 @@
 On those systems, it is automatically local in every buffer.
 On other systems, this variable is normally always nil.")
 
+;; Emacs 20.3 or later.
+(defvar-maybe minor-mode-overriding-map-alist nil
+  "Alist of keymaps to use for minor modes, in current major mode.
+APEL provides this as dummy for compatibility.")
+
 ;; Emacs 20.1/XEmacs 20.3(?) and later: (save-current-buffer &rest BODY)
 ;;
 ;; v20 defines `save-current-buffer' as a C primitive (in src/editfns.c)
@@ -1105,8 +1160,7 @@
 		    (buffer-string)))
 	       (si:replace-match newtext fixedcase literal)))))))))
 
-;; Emacs 20: (format-time-string)
-;; The the third optional argument universal is yet to be implemented.
+;; Emacs 20: (format-time-string FORMAT &optional TIME UNIVERSAL)
 ;; Those format constructs are yet to be implemented.
 ;;   %c, %C, %j, %U, %W, %x, %X
 ;; Not fully compatible especially when invalid format is specified.
@@ -1180,7 +1234,6 @@
 
 Compatibility Note.
 
-The the third optional argument universal is yet to be implemented.
 Those format constructs are yet to be implemented.
   %c, %C, %j, %U, %W, %x, %X
 Not fully compatible especially when invalid format is specified."
@@ -1195,9 +1248,24 @@
 	  field-result
 	  pad-left change-case
 	  (paren-level 0)
-	  hour
-	  (time-string (current-time-string time)))
-      (setq hour (string-to-int (substring time-string 11 13)))
+	  hour ms ls
+	  (tz (car (current-time-zone)))
+	  time-string)
+      (if universal
+	  (progn
+	    (or time
+		(setq time (current-time)))
+	    (setq ms (car time)
+		  ls (- (nth 1 time) tz))
+	    (cond ((< ls 0)
+		   (setq ms (1- ms)
+			 ls (+ ls 65536)))
+		  ((>= ls 65536)
+		   (setq ms (1+ ms)
+			 ls (- ls 65536))))
+	    (setq time (append (list ms ls) (nth 2 time)))))
+      (setq time-string (current-time-string time)
+	    hour (string-to-int (substring time-string 11 13)))
       (while (< ind fmt-len)
 	(setq cur-char (aref format ind))
 	(setq
@@ -1246,7 +1314,7 @@
 		(cond
 		 ((eq cur-char ?%)
 		  "%")
-		 ;; the abbreviated name of the day of week.		 
+		 ;; the abbreviated name of the day of week.
 		 ((eq cur-char ?a)
 		  (substring time-string 0 3))
 		 ;; the full name of the day of week
@@ -1267,7 +1335,7 @@
 		 ((eq cur-char ?C)
 		  "")
 		 ;; the day of month, zero-padded
-		 ((eq cur-char ?d)	
+		 ((eq cur-char ?d)
 		  (format "%02d" (string-to-int (substring time-string 8 10))))
 		 ;; a synonym for `%m/%d/%y'
 		 ((eq cur-char ?D)
@@ -1335,7 +1403,7 @@
 			  (substring time-string 11 13)
 			  (substring time-string 14 16)
 			  (substring time-string 17 19)))
-		 ;; the week of the year (01-52), assuming that weeks 
+		 ;; the week of the year (01-52), assuming that weeks
 		 ;; start on Sunday (yet to come)
 		 ((eq cur-char ?U)
 		  "")
@@ -1361,8 +1429,18 @@
 		  (substring time-string -4))
 		 ;; the time zone abbreviation
 		 ((eq cur-char ?Z)
-		  (setq change-case (not change-case))
-		  (downcase (cadr (current-time-zone))))
+		  (if universal
+		      "UTC"
+		    (setq change-case (not change-case))
+		    (downcase (cadr (current-time-zone)))))
+		 ((eq cur-char ?z)
+		  (if universal
+		      "+0000"
+		    (if (< tz 0)
+			(format "-%02d%02d"
+				(/ (- tz) 3600) (/ (% (- tz) 3600) 60))
+		      (format "+%02d%02d"
+			      (/ tz 3600) (/ (% tz 3600) 60)))))
 		 (t
 		  (concat
 		   "%"
@@ -1404,6 +1482,47 @@
   (setq current-load-list (cons 'format-time-string current-load-list))
   (put 'format-time-string 'defun-maybe t))))
 
+;; Emacs 19.29-19.34/XEmacs: `format-time-string' neither supports the
+;; format string "%z" nor the third argument `universal'.
+(unless (string-match "\\`[\\-\\+][0-9]+\\'"
+		      (format-time-string "%z" (current-time)))
+  (defadvice format-time-string
+    (before support-timezone-in-numeric-form-and-3rd-arg
+	    (format-string &optional time universal) activate compile)
+    "Advice to support the construct `%z' and the third argument `universal'."
+    (let ((tz (car (current-time-zone)))
+	  case-fold-search ms ls)
+      (while (string-match "\\(\\(\\`\\|[^%]\\)\\(%%\\)*\\)%z" format-string)
+	(setq format-string
+	      (concat (substring format-string 0 (match-end 1))
+		      (if universal
+			  "+0000"
+			(if (< tz 0)
+			    (format "-%02d%02d"
+				    (/ (- tz) 3600) (/ (% (- tz) 3600) 60))
+			  (format "+%02d%02d"
+				  (/ tz 3600) (/ (% tz 3600) 60))))
+		      (substring format-string (match-end 0)))))
+      (if universal
+	  (progn
+	    (while (string-match "\\(\\(\\`\\|[^%]\\)\\(%%\\)*\\)%Z"
+				 format-string)
+	      (setq format-string
+		    (concat (substring format-string 0 (match-end 1))
+			    "UTC"
+			    (substring format-string (match-end 0)))))
+	    (or time
+		(setq time (current-time)))
+	    (setq ms (car time)
+		  ls (- (nth 1 time) tz))
+	    (cond ((< ls 0)
+		   (setq ms (1- ms)
+			 ls (+ ls 65536)))
+		  ((>= ls 65536)
+		   (setq ms (1+ ms)
+			 ls (- ls 65536))))
+	    (setq time (append (list ms ls) (nth 2 time))))))))
+
 ;; Emacs 20.1/XEmacs 20.3(?) and later: (split-string STRING &optional PATTERN)
 ;; Here is a XEmacs version.
 (defun-maybe split-string (string &optional pattern)
@@ -1476,6 +1595,190 @@
 	  (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp"))))
   "The directory for writing temporary files.")
 
+;; Emacs 21 CVS         ; nothing to do.
+;;  (make-temp-file PREFIX &optional DIR-FLAG SUFFIX)
+;;
+;; Emacs 21.1-21.3      ; replace with CVS version of `make-temp-file'.
+;;  (make-temp-file PREFIX &optional DIR-FLAG)
+;;
+;; Emacs 20 and earlier ; install our version of `make-temp-file', for
+;;  or XEmacs		; single-user system or for multi-user system.
+(eval-when-compile
+  (cond
+   ((get 'make-temp-file 'defun-maybe)
+    ;; this form is already evaluated during compilation.
+    )
+   ((not (fboundp 'make-temp-file))
+    ;; Emacs 20 and earlier, or XEmacs.
+    (put 'make-temp-file 'defun-maybe 'none))
+   (t
+    (let* ((object (symbol-function 'make-temp-file))
+           (arglist (cond
+                     ((byte-code-function-p object)
+                      (if (fboundp 'compiled-function-arglist)
+                          (compiled-function-arglist object)
+                        (aref object 0)))
+                     ((eq (car-safe object) 'lambda)
+                      (nth 1 object))
+                     ;; `make-temp-file' is a built-in.
+                     )))
+      ;; arglist: (prefix &optional dir-flag suffix)
+      (cond
+       ((not arglist)
+        ;; `make-temp-file' is a built-in; expects 3-args.
+        (put 'make-temp-file 'defun-maybe '3-args))
+       ((> (length arglist) 3)
+        ;; Emacs 21 CVS.
+        (put 'make-temp-file 'defun-maybe '3-args))
+       (t
+        ;; Emacs 21.1-21.3
+        (put 'make-temp-file 'defun-maybe '2-args)))))))
+
+(static-cond
+ ((eq (get 'make-temp-file 'defun-maybe) '3-args)
+  (put 'make-temp-file 'defun-maybe '3-args))
+ ((eq (get 'make-temp-file 'defun-maybe) '2-args)
+  (put 'make-temp-file 'defun-maybe '2-args)
+  (or (fboundp 'si:make-temp-file)
+      (fset 'si:make-temp-file (symbol-function 'make-temp-file)))
+  (setq current-load-list (cons 'make-temp-file current-load-list))
+  (defun make-temp-file (prefix &optional dir-flag suffix)
+    "\
+Create a temporary file.
+The returned file name (created by appending some random characters at the end
+of PREFIX, and expanding against `temporary-file-directory' if necessary),
+is guaranteed to point to a newly created empty file.
+You can then use `write-region' to write new data into the file.
+
+If DIR-FLAG is non-nil, create a new empty directory instead of a file.
+
+If SUFFIX is non-nil, add that at the end of the file name."
+    (let ((umask (default-file-modes))
+          file)
+      (unwind-protect
+          (progn
+            ;; Create temp files with strict access rights.  
+            ;; It's easy toloosen them later, whereas it's impossible
+            ;;  to close the time-window of loose permissions otherwise.
+            (set-default-file-modes 448)
+            (while (condition-case ()
+                       (progn
+                         (setq file
+                               (make-temp-name
+                                (expand-file-name
+                                 prefix temporary-file-directory)))
+                         (if suffix
+                             (setq file (concat file suffix)))
+                         (if dir-flag
+                             (make-directory file)
+                           (write-region "" nil file nil
+                                         'silent nil 'excl))
+                         nil)
+                     (file-already-exists t))
+              ;; the file was somehow created by someone else between
+              ;; `make-temp-name' and `write-region', let's try again.
+              nil)
+            file)
+        ;; Reset the umask.
+        (set-default-file-modes umask)))))
+ ((eq (get 'make-temp-file 'defun-maybe) 'none)
+  (put 'make-temp-file 'defun-maybe 'none)
+  (setq current-load-list (cons 'make-temp-file current-load-list))
+  ;; must be load-time check to share .elc between different systems.
+  (cond
+   ((memq system-type '(windows-nt ms-dos OS/2 emx))
+    ;; for single-user systems.
+    (defun make-temp-file (prefix &optional dir-flag suffix)
+      "Create a temporary file.
+The returned file name (created by appending some random characters at the end
+of PREFIX, and expanding against `temporary-file-directory' if necessary),
+is guaranteed to point to a newly created empty file.
+You can then use `write-region' to write new data into the file.
+
+If DIR-FLAG is non-nil, create a new empty directory instead of a file.
+
+If SUFFIX is non-nil, add that at the end of the file name."
+      (let ((file (make-temp-name
+                   (expand-file-name prefix temporary-file-directory))))
+        (if suffix
+            (setq file (concat file suffix)))
+        (if dir-flag
+            (make-directory file)
+          (write-region "" nil file nil 'silent))
+        file)))
+   (t
+    ;; for multi-user systems.
+    (defun make-temp-file (prefix &optional dir-flag suffix)
+      "Create a temporary file.
+The returned file name (created by appending some random characters at the end
+of PREFIX, and expanding against `temporary-file-directory' if necessary),
+is guaranteed to point to a newly created empty file.
+You can then use `write-region' to write new data into the file.
+
+If DIR-FLAG is non-nil, create a new empty directory instead of a file.
+
+If SUFFIX is non-nil, add that at the end of the file name."
+      (let ((prefix (expand-file-name prefix temporary-file-directory)))
+        (if dir-flag
+            ;; Create a new empty directory.
+            (let (dir)
+              (while (condition-case ()
+                         (progn
+                           (setq dir (make-temp-name prefix))
+                           (if suffix
+                               (setq dir (concat dir suffix)))
+                           ;; `make-directory' returns nil for success,
+                           ;; otherwise signals an error.
+                           (make-directory dir))
+                       ;; the dir was somehow created by someone else
+                       ;; between `make-temp-name' and `make-directory',
+                       ;; let's try again.
+                       (file-already-exists t)))
+              (set-file-modes dir 448)
+              dir)
+          ;; Create a new empty file.
+          (let (tempdir tempfile)
+            (unwind-protect
+                (let (file)
+                  ;; First, create a temporary directory.
+                  (while (condition-case ()
+                             (progn
+                               (setq tempdir (make-temp-name
+                                              (concat
+                                               (file-name-directory prefix)
+                                               "DIR")))
+                               ;; return nil or signal an error.
+                               (make-directory tempdir))
+                           ;; let's try again.
+                           (file-already-exists t)))
+                  (set-file-modes tempdir 448)
+                  ;; Second, create a temporary file in the tempdir.
+                  ;; There *is* a race condition between `make-temp-name'
+                  ;; and `write-region', but we don't care it since we are
+                  ;; in a private directory now.
+                  (setq tempfile (make-temp-name (concat tempdir "/EMU")))
+                  (write-region "" nil tempfile nil 'silent)
+                  (set-file-modes tempfile 384)
+                  ;; Finally, make a hard-link from the tempfile.
+                  (while (condition-case ()
+                             (progn
+                               (setq file (make-temp-name prefix))
+                               (if suffix
+                                   (setq file (concat file suffix)))
+                               ;; return nil or signal an error.
+                               (add-name-to-file tempfile file))
+                           ;; let's try again.
+                           (file-already-exists t)))
+                  file)
+              ;; Cleanup the tempfile.
+              (and tempfile
+                   (file-exists-p tempfile)
+                   (delete-file tempfile))
+              ;; Cleanup the tempdir.
+              (and tempdir
+                   (file-directory-p tempdir)
+                   (delete-directory tempdir)))))))))))
+
 ;; Actually, `path-separator' is defined in src/emacs.c and overrided
 ;; in dos-w32.el.
 (defvar-maybe path-separator ":"
@@ -1555,6 +1858,19 @@
 	filename))))
 
 
+;;; @ Miscellanea.
+
+;; Emacs 19.29 and later: (current-fill-column)
+(defun-maybe current-fill-column ()
+  "Return the fill-column to use for this line."
+  fill-column)
+
+;; Emacs 19.29 and later: (current-left-margin)
+(defun-maybe current-left-margin ()
+  "Return the left margin to use for this line."
+  left-margin)
+
+
 ;;; @ XEmacs emulation.
 ;;;
 
@@ -1648,10 +1964,10 @@
   ((and (fboundp 'read-event)
 	(subrp (symbol-function 'read-event)))
    ;; Emacs 19, 20.1 and 20.2.
-   (if prompt (message prompt))
+   (if prompt (message "%s" prompt))
    (read-event))
   (t
-   (if prompt (message prompt))
+   (if prompt (message "%s" prompt))
    (read-char)))
 
 
Index: poem-xm.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/poem-xm.el,v
retrieving revision 1.3
diff -u -r1.3 poem-xm.el
--- poem-xm.el	10 Jul 2000 04:41:06 -0000	1.3
+++ poem-xm.el	2 Dec 2005 10:07:40 -0000
@@ -68,12 +68,19 @@
   "Return index of character succeeding CHAR whose index is INDEX."
   `(1+ ,index))
 
+(defun-maybe char-length (char)
+  "Return indexing length of multi-byte form of CHAR."
+  1)
+
 
 ;;; @ string
 ;;;
 
 (defun-maybe string-to-int-list (str)
   (mapcar #'char-int str))
+
+(defun-maybe string-to-char-list (str)
+  (mapcar #'identity str))
 
 (defalias 'looking-at-as-unibyte 'looking-at)
 
Index: product.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/product.el,v
retrieving revision 1.2
diff -u -r1.2 product.el
--- product.el	6 Oct 2000 08:33:45 -0000	1.2
+++ product.el	2 Dec 2005 10:07:40 -0000
@@ -1,6 +1,6 @@
 ;;; product.el --- Functions for product version information.
 
-;; Copyright (C) 1999 Free Software Foundation, Inc.
+;; Copyright (C) 1999,2000 Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
 ;;	Keiichi Suzuki <keiichi@nanap.org>
@@ -135,7 +135,7 @@
   "Add checker function(s) to a product.
 PRODUCT is a product structure which returned by `product-define'.
 The rest arguments CHECKERS should be functions.  These functions
-are regist to the product's checkers list, and will be called by
+are registered to the product's checkers list, and will be called by
  `product-run-checkers'.
 If a checker is `ignore' will be ignored all checkers after this."
   (setq product (product-find product))
@@ -248,6 +248,19 @@
 			  nil nil nil (, product-version-string)))))
 	 (, feature-def)))))
 
+(defun product-version-as-string (product)
+  "Return version number of product as a string.
+PRODUCT is a product structure which returned by `product-define'.
+If optional argument UPDATE is non-nil, then regenerate
+`product-version-string' from `product-version'."
+  (setq product (product-find product))
+  (or (product-version-string product)
+      (and (product-version product)
+	   (product-set-version-string product
+				       (mapconcat (function int-to-string)
+						  (product-version product)
+						  ".")))))
+
 (defun product-string-1 (product &optional verbose)
   "Return information of product as a string of \"NAME/VERSION\".
 PRODUCT is a product structure which returned by `product-define'.
@@ -255,20 +268,11 @@
 \"NAME/VERSION (CODE-NAME)\"."
   (setq product (product-find product))
   (concat (product-name product)
-	  (cond
-	   ((product-version-string product)
-	    (concat "/" (product-version-string product)))
-	   ((product-version product)
-	    (concat "/"
-		    (product-set-version-string
-		     product
-		     (mapconcat (function int-to-string)
-				(product-version product)
-				"."))))
-	   (""))
-	  (if (and verbose (product-code-name product))
-	      (concat " (" (product-code-name product) ")")
-	    "")))
+	  (let ((version-string (product-version-as-string product)))
+	    (and version-string
+		 (concat "/" version-string)))
+	  (and verbose (product-code-name product)
+	       (concat " (" (product-code-name product) ")"))))
 
 (defun product-for-each (product all function &rest args)
   "Apply a function to a product and the product's family with args.
Index: pym.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/pym.el,v
retrieving revision 1.1
diff -u -r1.1 pym.el
--- pym.el	10 Jul 2000 04:41:06 -0000	1.1
+++ pym.el	2 Dec 2005 10:07:40 -0000
@@ -27,12 +27,15 @@
 
 ;; This module provides `def*-maybe' macros for conditional definition.
 ;;
-;; Many APEL modules use these macros to provide emulation version of
-;; Emacs builtins (both C primitives and lisp subroutines) for backward
-;; compatibility.  While compilation time, if `def*-maybe' find that
-;; functions/variables being defined is already provided by Emacs used
-;; for compilation, it does not leave the definitions in compiled code
-;; and resulting .elc will be highly specialized for your environment.
+;; Many APEL modules use these macros to provide the emulating version
+;; of the Emacs builtins (both C primitives and lisp subroutines) for
+;; backward compatibility.  While compilation time, if `def*-maybe'
+;; find that functions/variables being defined is already provided by
+;; Emacs used for compilation, it does not leave the definitions in
+;; compiled code and resulting .elc files will be highly specialized
+;; for your environment.  Lisp programmers should be aware that these
+;; macros will never provide functions or variables at run-time if they
+;; are defined for some reason (or by accident) at compilation time.
 
 ;; For `find-function' lovers, the following definitions may work with
 ;; `def*-maybe'.
@@ -268,7 +271,7 @@
 	   &rest (&rest sexp)))
 
 ;; edebug-spec for `static-*' macros are also defined here.
-(def-edebug-spec static-if if) 
+(def-edebug-spec static-if t) 
 (def-edebug-spec static-when when)
 (def-edebug-spec static-unless unless)
 (def-edebug-spec static-condition-case condition-case)
Index: richtext.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/richtext.el,v
retrieving revision 1.2
diff -u -r1.2 richtext.el
--- richtext.el	10 Jul 2000 04:41:06 -0000	1.2
+++ richtext.el	2 Dec 2005 10:07:40 -0000
@@ -4,7 +4,7 @@
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Created: 1995/7/15
-;; Version: $Id: richtext.el,v 1.1.1.1 1998/01/14 06:31:32 steve Exp $
+;; Version: $Id: richtext.el,v 3.6 1997/06/28 17:58:34 morioka Exp $
 ;; Keywords: wp, faces, MIME, multimedia
 
 ;; This file is not part of GNU Emacs yet.
Index: static.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/apel/static.el,v
retrieving revision 1.3
diff -u -r1.3 static.el
--- static.el	10 Jul 2000 04:41:06 -0000	1.3
+++ static.el	2 Dec 2005 10:07:40 -0000
@@ -26,27 +26,27 @@
 
 (put 'static-if 'lisp-indent-function 2)
 (defmacro static-if (cond then &rest else)
-  "`if' expression but COND is evaluated at compile-time."
+  "Like `if', but evaluate COND at compile time."
   (if (eval cond)
       then
     (` (progn  (,@ else)))))
 
 (put 'static-when 'lisp-indent-function 1)
 (defmacro static-when (cond &rest body)
-  "`when' expression but COND is evaluated at compile-time."
+  "Like `when', but evaluate COND at compile time."
   (if (eval cond)
       (` (progn (,@ body)))))
 
 (put 'static-unless 'lisp-indent-function 1)
 (defmacro static-unless (cond &rest body)
-  "`unless' expression but COND is evaluated at compile-time."
+  "Like `unless', but evaluate COND at compile time."
   (if (eval cond)
       nil
     (` (progn (,@ body)))))
 
 (put 'static-condition-case 'lisp-indent-function 2)
 (defmacro static-condition-case (var bodyform &rest handlers)
-  "`condition-case' expression but BODYFORM is evaluated at compile-time."
+  "Like `condition-case', but evaluate BODYFORM at compile time."
   (eval (` (condition-case (, var)
 	       (list (quote quote) (, bodyform))
 	     (,@ (mapcar
@@ -64,15 +64,15 @@
 
 (put 'static-defconst 'lisp-indent-function 'defun)
 (defmacro static-defconst (symbol initvalue &optional docstring)
-  "`defconst' expression but INITVALUE is evaluated at compile-time.
+  "Like `defconst', but evaluate INITVALUE at compile time.
 
-The variable SYMBOL can be referenced at either compile-time or run-time."
+The variable SYMBOL can be referred at both compile time and run time."
   (let ((value (eval initvalue)))
     (eval (` (defconst (, symbol) (quote (, value)) (, docstring))))
     (` (defconst (, symbol) (quote (, value)) (, docstring)))))
 
 (defmacro static-cond (&rest clauses)
-  "`cond' expression but the car of each clause is evaluated at compile-time."
+  "Like `cond', but evaluate CONDITION part of each clause at compile time."
   (while (and clauses
 	      (not (eval (car (car clauses)))))
     (setq clauses (cdr clauses)))
