Anonymous avatar Anonymous committed e07b8e4

apel-9.20, package-standards update

Comments (0)

Files changed (30)

-1999-05-19  SL Baur  <steve@gneiss.etl.go.jp>
-
-	* mcs-20.el (mime-charset-to-coding-system): Make defun instead of 
-	defsubst for portable bytecode.
-
+1999-07-06  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* APEL: Version 9.20 released.
+
+1999-06-27  OKUNISHI Fujikazu <fuji0924@mbox.kyoto-inet.or.jp>
+
+	* EMU-ELS: Install env.el for v18. <cf. [tm-ja:4710]>
+
+1999-06-25  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* poem-xm.el (split-char): Don't redefine for the recent XEmacs.
+
+1999-06-23  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poe.el (defun-maybe, defmacro-maybe, defalias-maybe,
+	defsubst-maybe, defun-maybe-cond, defmacro-maybe-cond):
+	Set `current-load-list' explicitly.
+
+1999-06-22  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* atype.el: Require 'poe.
+
+	* mule-caesar.el: Require 'poe and 'poem.
+
+	* filename.el: Require 'poe and 'poem.
+	Don't require 'cl.
+	(filename-special-filter): Eliminate `assoc-if'.
+
+1999-06-22  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* install.el: Require 'emu for backward compatibility.
+	(defun-maybe): New macro; imported from poe.el.
+	(make-directory-internal, make-directory): New functions; imported
+	from poe-18.el.
+
+	* APEL-CFG: Provide 'emu to prevent install.el from loading emu
+	while compiling APEL itself.
+
+1999-06-20  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* install.el: Require 'poe instead of 'emu.
+	(install-prefix): Don't use `running-emacs-18' or `running-xemacs'.
+	(install-detect-elisp-directory): Eliminate local variable `dir'.
+	Don't use `running-emacs-19_29-or-later' or `running-xemacs'.
+
+	* mcs-20.el: Require 'pcustom instead of 'custom.
+
+	* EMU-ELS: Don't use `running-emacs-19_29-or-later' or
+	`running-xemacs-19_14-or-later.'
+
+1999-06-18  Tanaka Akira      <akr@jaist.ac.jp>
+
+	* static.el (static-condition-case): Wrap lambda expression by
+	`function'.
+
+	* calist.el (calist-default-field-match-method): Use `function'
+	instead of #'.
+
+1999-06-17  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* pcustom.el: Load "custom" anyway.
+
+1999-06-16  Katsumi Yamaoka   <yamaoka@jpl.org>
+
+	* static.el (static-cond): New macro.
+
+1999-06-11  Tanaka Akira      <akr@jaist.ac.jp>
+
+	* static.el (static-defconst): New macro.
+
+1999-06-04  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* pces-xfc.el (insert-file-contents-literally-treats-binary): New
+	facility.
+	(insert-file-contents-literally-treats-file-name-handler): New
+	facility.
+	(insert-file-contents-as-binary): Define as an alias for
+	`insert-file-contents-literally' if it is not broken.
+
+1999-06-04  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* EMU-ELS (pces-modules): New variable.
+
+	* poem.el: Require pces.el.
+
+	* pces.el: New module.
+
+	* poem-xfc.el: Deleted.
+
+	* pces-xfc.el: New module.
+
+	* pces-nemacs.el: New module.
+
+	* poem-nemacs.el: Split off features about coding-system to
+	pces-nemacs.el.
+
+	* pces-om.el: New module.
+
+	* poem-om.el: Split off features about coding-system to
+	pces-om.el.
+
+	* pces-raw.el: New module.
+
+	* poem-ltn1.el: Split off features about coding-system to
+	pces-raw.el.
+
+	* pces-xm.el: New module.
+
+	* poem-xm.el: Split off features about coding-system to
+	pces-xm.el.
+
+	* pces-e20_2.el: New module.
+
+	* poem-e20_2.el: Split off features about coding-system to
+	pces-e20_2.el.
+
+	* pces-e20.el: New module.
+
+	* poem-e20.el (find-coding-system): Moved to pces-e20.el.
+	(set-process-input-coding-system): Likewise.
+	- Don't require `poem-20'.
+
+	* pces-20.el: New module [renamed from poem-20.el].
+
+1999-05-31  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* calist.el (calist-field-match-method): Fix problem when
+	`field-type' is a string.
+
+1999-05-27  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* calist.el (use-calist-package): New function.
+	(make-calist-package): Add new optional argument `use'.
+
+1999-05-27  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* calist.el (calist-package-alist): New variable.
+	(make-calist-package): New function.
+	(find-calist-package): New function.
+	(in-calist-package): New function.
+	(standard): New calist package.
+	(calist-field-match-method): Use method for `t' as a default
+	method; set up `calist-default-field-match-method' as method for
+	`t' of `standard' package.
+
+
+1999-05-26  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* APEL: Version 9.19 released.
+
+1999-05-25  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poe.el: Do not try to require 'edebug; it will be autoloaded.
+
+1999-05-24  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poem-om.el (char-before, char-after): Moved to poe.el.
+
+	* poe.el (char-before, char-after): Moved from poem-om.el.
+	Add definition for non-Mule.
+
+1999-05-24  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* poe.el (def-edebug-spec): New macro.
+	(defun-maybe): Use `def-edebug-spec'.
+	(defmacro-maybe): Likewise.
+	(defsubst-maybe): Likewise.
+	(read-string): Use `static-unless'.
+
+1999-05-21  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* README.en: Add description of localhook.el.
+
+	* README.ja: Ditto.
+
+	* Makefile (GOMI): New variable.
+	(clean): Use `RM' and `GOMI'.
+
+1999-05-21  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* mcs-20.el (detect-mime-charset-region): Use
+	`find-mime-charset-by-charsets'.
+
+	* mcharset.el (find-mime-charset-by-charsets): New function.
+
+1999-05-21  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* mcharset.el: Require pcustom.
+	(default-mime-charset-for-write): New variable [moved from
+	mcs-20.el].
+	(default-mime-charset-detect-method-for-write): Likewise.
+
+	* mcs-20.el (default-mime-charset-for-write): Abolished [moved to
+	mcharset.el].
+	(default-mime-charset-detect-method-for-write): Likewise.
+
+	* EMU-ELS: Don't install `localhook' for XEmacs.
+
+1999-05-19  MORIOKA Tomohiko  <tomo@m17n.org>
+
+	* mcs-20.el (mime-charset-to-coding-system): Don't use `defsubst'
+	to avoid problem in XEmacs binary distributions.
+
+1999-05-17  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poe-18.el (eval-when-compile, eval-and-compile): Reverted.
+
+1999-05-16  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* pcustom.el (toplevel): Require 'poe.
+
+1999-05-16  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* localhook.el (toplevel): Move provide to the top to avoid
+	circular dependency.
+
+1999-05-16  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poe-18.el (inline): New alias for `progn'.
+	(make-obsolete-variable): New function.
+	(dont-compile): New macro.
+
+1999-05-16  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poe.el (subr-fboundp): Use `defun' instead of `defsubst'.
+
+1999-05-16  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poem-om.el (insert-binary-file-contents-literally): Removed,
+	since provided by emu.el.
+	(char-before, char-after): Use `fboundp', not `boundp'.
+	Use error-conditions directly.
+
+1999-05-15  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poe.el (path-separator): Doc sync with 20.3.
+	(add-to-list): Ditto.
+	(buffer-live-p): Return bool value.
+	(cadr, cdar, cddr): New functions.
+	(save-current-buffer): Check whether `orig-buffer' is alive.
+	(functionp): Sync with 20.3; use `car-safe'.
+	(line-beginning-position, line-end-position): Use `forward-line'
+	or `end-of-line' only.
+	(point-at-bol, point-at-eol): Ditto.
+
+1999-05-15  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* localhook.el: New file; local hook variable support.
+
+	* poe.el (add-hook, remove-hook, make-local-hook): Removed;
+	require 'localhook instead.
+
+	* poe-18.el: (default-boundp): New function.
+
+	* EMU-ELS: Added localhook.
+
+1999-05-14  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* pcustom.el: Rewrite using static.el.
+
+	* tinycustom.el (defface): Use `defmacro-maybe-cond'.
+
+	* EMU-ELS: Compilation order of tinycustom and pcustom was changed.
+
+1999-05-14  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poe-18.el: Require 'poe.
+	Move provide to the top to avoid circular dependency.
+	(eval-when-compile, eval-and-compile): Modified for old compiler.
+	(defsubst): Moved from poe.el.
+	(make-obsolete): Do nothing.
+
+	* poe.el (read-string): Don't use `eval-and-compile'.
+
+1999-05-14  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+	* poe.el (defmacro-maybe-cond): New macro.
+	(defun-maybe, defmacro-maybe, defsubst-maybe, defalias-maybe,
+	defvar-maybe, defconst-maybe, defun-maybe-cond): Return NAME.
+	(defun-maybe, defmacro-maybe, defsubst-maybe): Put edebug spec.
+	(defsubst): Moved to poe-18.el.
+
+1999-05-13  Tanaka Akira      <akr@jaist.ac.jp>
+
+	* pccl-om.el: pccl-om.el does not support Mule 1.*.
+
+1999-05-10  Daiki Ueno        <ueno@ueda.info.waseda.ac.jp>
+
+	* tinycustom.el (define-widget): Accept the optional arguments.
+
+1999-05-08  Tanaka Akira      <akr@jaist.ac.jp>
+
+	* README.en (What's APEL?): Add notice for static.el.
+
+	* README.ja: Ditto.
+
+
 1999-05-08  MORIOKA Tomohiko  <tomo@m17n.org>
 
 	* APEL: Version 9.18 released.
 
 	* APEL: Version 8.4 was released.
 
-	* EMU-ELS: Don't use HIRAGANA LETTER A ($B$"(B) to detect character
+	* EMU-ELS: Don't use HIRAGANA LETTER A ($(B$"(B) to detect character
  	indexing (Emacs 20.3 or later).
 
 1998-04-20  MORIOKA Tomohiko  <morioka@jaist.ac.jp>
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.13
-AUTHOR_VERSION = 9.18
+VERSION = 1.14
+AUTHOR_VERSION = 9.20
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = apel
 PKG_TYPE = regular
 REQUIRES = fsf-compat xemacs-base
 CATEGORY = libs
 
-ELCS = atype.elc broken.elc calist.elc emu.elc file-detect.elc filename.elc \
+ELCS = broken.elc calist.elc emu.elc filename.elc \
 	install.elc inv-xemacs.elc invisible.elc mcharset.elc mcs-20.elc \
 	mcs-ltn1.elc mule-caesar.elc path-util.elc pccl.elc poe-xemacs.elc \
-	poe.elc poem-20.elc poem-ltn1.elc poem-xfc.elc poem-xm.elc poem.elc \
-	richtext.elc std11-parse.elc std11.elc tinyrich.elc
+	poe.elc poem-ltn1.elc poem-xm.elc poem.elc \
+	richtext.elc static.elc \
+	pcustom.elc pces.elc pces-raw.elc pces-20.elc pces-xfc.elc
+EXTRA_SOURCES = README.en
 
-EXTRA_SOURCES = README.en
+PRELOADS = -eval "(push \"`pwd`\" load-path)" -l ./poe.el
 
 include ../../XEmacs.rules
 
 ifeq ($(BUILD_MULE),t)
 # ELCS += emu-x20.elc
-ELCS += emu-mule.elc mcs-xm.elc pccl-20.elc
+ELCS += emu-mule.elc mcs-xm.elc pccl-20.elc pces-xm.elc 
 EXTRA_SOURCES += README.ja
 endif
 
       poe-xemacs.el  --- for XEmacs
       poe-18.el	     --- for Emacs 18/Nemacs
          env.el      --- env.el for Emacs 18
+      localhook.el   --- hook functions for Emacs 19.28 and earlier.
 
     poem.el --- provide basic functions to write portable MULE
 		programs
       mcs-e20.el    --- for Emacs 20
       mcs-xm.el     --- for XEmacs-MULE
 
-    broken.el --- provide information of broken facilities of Emacs.
+    static.el --- utility for static evaluation
+
+    broken.el --- provide information of broken facilities of Emacs
 
     pccl.el --- utility to write portable CCL program
       pccl-om.el --- for MULE 2.*
       poe-xemacs.el  --- XEmacs$BMQ(B
       poe-18.el	     --- Emacs 18/Nemacs $BMQ(B
          env.el      --- Emacs 18 $BMQ$N(B env.el
+      localhook.el   --- Emacs 18 $B$H(B Emacs 19.28 $B0JA0MQ$N(B hook $B4X?t72(B
 
     poem.el --- $B0\?"@-$N9b$$(B MULE $B%W%m%0%i%`$r=q$/$?$a$N4pACE*$J4X?t$r(B
 		$BDs6!$9$k(B
       mcs-e20.el    --- Emacs 20 $BMQ(B
       mcs-xm.el     --- XEmacs-MULE $BMQ(B
 
+    static.el --- $B@EE*I>2A$N$?$a$N%f!<%F%#%j%F%#!<(B
+
     broken.el --- Emacs $B$N2u$l$F$$$k5!G=$N>pJs$rDs6!$9$k(B
 
     pccl.el --- $B0\?"2DG=$J(B CCL $B%W%m%0%i%`$r=q$/$?$a$N%f!<%F%#%j%F%#!<(B

atype.el

-;;; atype.el --- atype functions
-
-;; Copyright (C) 1994,1995,1996,1997 Free Software Foundation, Inc.
-
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id$
-;; Keywords: atype
-
-;; This file is part of APEL (A Portable Emacs Library).
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
-
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Code:
-
-(require 'emu)
-(require 'alist)
-
-
-;;; @ field unifier
-;;;
-
-(defun field-unifier-for-default (a b)
-  (let ((ret
-	 (cond ((equal a b)    a)
-	       ((null (cdr b)) a)
-	       ((null (cdr a)) b)
-	       )))
-    (if ret
-	(list nil ret nil)
-      )))
-
-(defun field-unify (a b)
-  (let ((f
-	 (let ((type (car a)))
-	   (and (symbolp type)
-		(intern (concat "field-unifier-for-" (symbol-name type)))
-		))))
-    (or (fboundp f)
-	(setq f (function field-unifier-for-default))
-	)
-    (funcall f a b)
-    ))
-
-
-;;; @ type unifier
-;;;
-
-(defun assoc-unify (class instance)
-  (catch 'tag
-    (let ((cla (copy-alist class))
-	  (ins (copy-alist instance))
-	  (r class)
-	  cell aret ret prev rest)
-      (while r
-	(setq cell (car r))
-	(setq aret (assoc (car cell) ins))
-	(if aret
-	    (if (setq ret (field-unify cell aret))
-		(progn
-		  (if (car ret)
-		      (setq prev (put-alist (car (car ret))
-					    (cdr (car ret))
-					    prev))
-		    )
-		  (if (nth 2 ret)
-		      (setq rest (put-alist (car (nth 2 ret))
-					    (cdr (nth 2 ret))
-					    rest))
-		    )
-		  (setq cla (put-alist (car cell)(cdr (nth 1 ret)) cla))
-		  (setq ins (del-alist (car cell) ins))
-		  )
-	      (throw 'tag nil)
-	      ))
-	(setq r (cdr r))
-	)
-      (setq r (copy-alist ins))
-      (while r
-	(setq cell (car r))
-	(setq aret (assoc (car cell) cla))
-	(if aret
-	    (if (setq ret (field-unify cell aret))
-		(progn
-		  (if (car ret)
-		      (setq prev (put-alist (car (car ret))
-					    (cdr (car ret))
-					    prev))
-		    )
-		  (if (nth 2 ret)
-		      (setq rest (put-alist (car (nth 2 ret))
-					    (cdr (nth 2 ret))
-					    rest))
-		    )
-		  (setq cla (del-alist (car cell) cla))
-		  (setq ins (put-alist (car cell)(cdr (nth 1 ret)) ins))
-		  )
-	      (throw 'tag nil)
-	      ))
-	(setq r (cdr r))
-	)
-      (list prev (append cla ins) rest)
-      )))
-
-(defun get-unified-alist (db al)
-  (let ((r db) ret)
-    (catch 'tag
-      (while r
-	(if (setq ret (nth 1 (assoc-unify (car r) al)))
-	    (throw 'tag ret)
-	  )
-	(setq r (cdr r))
-	))))
-
-
-;;; @ utilities
-;;;
-
-(defun delete-atype (atl al)
-  (let* ((r atl) ret oal)
-    (setq oal
-	  (catch 'tag
-	    (while r
-	      (if (setq ret (nth 1 (assoc-unify (car r) al)))
-		  (throw 'tag (car r))
-		)
-	      (setq r (cdr r))
-	      )))
-    (delete oal atl)
-    ))
-
-(defun remove-atype (sym al)
-  (and (boundp sym)
-       (set sym (delete-atype (eval sym) al))
-       ))
-
-(defun replace-atype (atl old-al new-al)
-  (let* ((r atl) ret oal)
-    (if (catch 'tag
-	  (while r
-	    (if (setq ret (nth 1 (assoc-unify (car r) old-al)))
-		(throw 'tag (rplaca r new-al))
-	      )
-	    (setq r (cdr r))
-	    ))
-	atl)))
-
-(defun set-atype (sym al &rest options)
-  (if (null (boundp sym))
-      (set sym al)
-    (let* ((replacement (memq 'replacement options))
-	   (ignore-fields (car (cdr (memq 'ignore options))))
-	   (remove (or (car (cdr (memq 'remove options)))
-		       (let ((ral (copy-alist al)))
-			 (mapcar (function
-				  (lambda (type)
-				    (setq ral (del-alist type ral))
-				    ))
-				 ignore-fields)
-			 ral)))
-	   )
-      (set sym
-	   (or (if replacement
-		   (replace-atype (eval sym) remove al)
-		 )
-	       (cons al
-		     (delete-atype (eval sym) remove)
-		     )
-	       )))))
-
-
-;;; @ end
-;;;
-
-(provide 'atype)
-
-;;; atype.el ends here
 ;;; calist.el --- Condition functions
 
-;; Copyright (C) 1998 MORIOKA Tomohiko.
+;; Copyright (C) 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1999 Electrotechnical Laboratory, JAPAN.
+;; Licensed to the Free Software Foundation.
 
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
 ;; Keywords: condition, alist, tree
 
 ;; This file is part of APEL (A Portable Emacs Library).
 
 (eval-when-compile (require 'cl))
 
-(defvar calist-field-match-method-obarray [nil])
+(require 'alist)
+
+(defvar calist-package-alist nil)
+(defvar calist-field-match-method-obarray nil)
+
+(defun find-calist-package (name)
+  "Return a calist-package by NAME."
+  (cdr (assq name calist-package-alist)))
 
 (defun define-calist-field-match-method (field-type function)
   "Set field-match-method for FIELD-TYPE to FUNCTION."
   (fset (intern (symbol-name field-type) calist-field-match-method-obarray)
 	function))
 
+(defun use-calist-package (name)
+  "Make the symbols of package NAME accessible in the current package."
+  (mapatoms (lambda (sym)
+	      (if (intern-soft (symbol-name sym)
+			       calist-field-match-method-obarray)
+		  (signal 'conflict-of-calist-symbol
+			  (list (format "Conflict of symbol %s")))
+		(if (fboundp sym)
+		    (define-calist-field-match-method
+		      sym (symbol-function sym))
+		  )))
+	    (find-calist-package name)))
+
+(defun make-calist-package (name &optional use)
+  "Create a new calist-package."
+  (let ((calist-field-match-method-obarray (make-vector 7 0)))
+    (set-alist 'calist-package-alist name
+	       calist-field-match-method-obarray)
+    (use-calist-package (or use 'standard))
+    calist-field-match-method-obarray))
+
+(defun in-calist-package (name)
+  "Set the current calist-package to a new or existing calist-package."
+  (setq calist-field-match-method-obarray
+	(or (find-calist-package name)
+	    (make-calist-package name))))
+
+(in-calist-package 'standard)
+
 (defun calist-default-field-match-method (calist field-type field-value)
   (let ((s-field (assoc field-type calist)))
     (cond ((null s-field)
 	  ((equal (cdr s-field) field-value)
 	   calist))))
 
+(define-calist-field-match-method t (function calist-default-field-match-method))
+
 (defsubst calist-field-match-method (field-type)
-  (condition-case nil
-      (symbol-function
-       (intern-soft
-	(symbol-name field-type) calist-field-match-method-obarray))
-    (error (symbol-function 'calist-default-field-match-method))
-    ))
+  (symbol-function
+   (or (intern-soft (if (symbolp field-type)
+			(symbol-name field-type)
+		      field-type)
+		    calist-field-match-method-obarray)
+       (intern-soft "t" calist-field-match-method-obarray))))
 
 (defsubst calist-field-match (calist field-type field-value)
   (funcall (calist-field-match-method field-type)

emu-x21.el

-;;; emu-x21.el --- emu module for XEmacs 21 file-coding (non-mule)
-
-;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
-
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id$
-;; Keywords: emulation, compatibility, mule, Latin-1
-
-;; This file is part of emu.
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
-
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Code:
-
-;;; @ version and variant specific features
-;;;
-
-(require 'emu-xemacs)
-
-;;; @ character set
-;;; xemacs 21 with file coding has coding stuff but not charset stuff.
-
-(defconst charset-ascii 0 "Character set of ASCII")
-(defconst charset-latin-iso8859-1 129 "Character set of ISO-8859-1")
-
-(defun charset-description (charset)
-  "Return description of CHARSET. [emu-x21.el]"
-  (if (< charset 128)
-      (documentation-property 'charset-ascii 'variable-documentation)
-    (documentation-property 'charset-latin-iso8859-1 'variable-documentation)
-    ))
-
-(defun charset-registry (charset)
-  "Return registry name of CHARSET. [emu-x21.el]"
-  (if (< charset 128)
-      "ASCII"
-    "ISO8859-1"))
-
-(defun charset-columns (charset)
-  "Return number of columns a CHARSET occupies when displayed.
-\[emu-x21.el]"
-  1)
-
-(defun charset-direction (charset)
-  "Return the direction of a character of CHARSET by
-  0 (left-to-right) or 1 (right-to-left). [emu-x21.el]"
-  0)
-
-(defun find-charset-string (str)
-  "Return a list of charsets in the string.
-\[emu-x21.el; Mule emulating function]"
-  (if (string-match "[\200-\377]" str)
-      (list charset-latin-iso8859-1)
-    ))
-
-(defalias 'find-non-ascii-charset-string 'find-charset-string)
-
-(defun find-charset-region (start end)
-  "Return a list of charsets in the region between START and END.
-\[emu-x21.el; Mule emulating function]"
-  (if (save-excursion
-	(save-restriction
-	  (narrow-to-region start end)
-	  (goto-char start)
-	  (re-search-forward "[\200-\377]" nil t)
-	  ))
-      (list charset-latin-iso8859-1)
-    ))
-
-(defalias 'find-non-ascii-charset-region 'find-charset-region)
-
-
-;;; @ coding-system
-;;;
-
-(defconst *internal* nil)
-(defconst *ctext* nil)
-(defconst *noconv* nil)
-
-(defmacro as-binary-process (&rest body)
-  `(let (selective-display	; Disable ^M to nl translation.
-	 (coding-system-for-read  'binary)
-	 (coding-system-for-write 'binary))
-     ,@body))
-
-(defmacro as-binary-input-file (&rest body)
-  `(let ((coding-system-for-read 'binary))
-     ,@body))
-
-(defmacro as-binary-output-file (&rest body)
-  `(let ((coding-system-for-write 'binary))
-     ,@body))
-
-;;; @@ for old MULE emulation
-;;;
-
-(defun code-convert-string (str ic oc)
-  "Convert code in STRING from SOURCE code to TARGET code,
-On successful converion, returns the result string,
-else returns nil. [emu-e19.el; old MULE emulating function]"
-  str)
-
-(defun code-convert-region (beg end ic oc)
-  "Convert code of the text between BEGIN and END from SOURCE
-to TARGET. On successful conversion returns t,
-else returns nil. [emu-e19.el; old MULE emulating function]"
-  t)
-
-
-;;; @ binary access
-;;;
-
-(defun insert-binary-file-contents-literally
-  (filename &optional visit beg end replace)
-  "Like `insert-file-contents-literally', q.v., but don't code conversion.
-A buffer may be modified in several ways after reading into the buffer due
-to advanced Emacs features, such as file-name-handlers, format decoding,
-find-file-hooks, etc.
-  This function ensures that none of these modifications will take place."
-  (let ((coding-system-for-read 'binary))
-    (insert-file-contents-literally filename visit beg end replace)
-    ))
-
-;;; @ MIME charset
-;;;
-
-(defvar charsets-mime-charset-alist
-  (list (cons (list charset-ascii) 'us-ascii)))
-
-(defvar default-mime-charset 'iso-8859-1)
-
-(defun mime-charset-to-coding-system (charset)
-  (if (stringp charset)
-      (setq charset (intern (downcase charset)))
-    )
-  (and (memq charset (list 'us-ascii default-mime-charset))
-       charset)
-  )
-
-(defun detect-mime-charset-region (start end)
-  "Return MIME charset for region between START and END.
-\[emu-x21.el]"
-  (if (save-excursion
-	(save-restriction
-	  (narrow-to-region start end)
-	  (goto-char start)
-	  (re-search-forward "[\200-\377]" nil t)
-	  ))
-      default-mime-charset
-    'us-ascii))
-
-(defun encode-mime-charset-region (start end charset)
-  "Encode the text between START and END as MIME CHARSET.
-\[emu-x21.el]"
-  )
-
-(defun decode-mime-charset-region (start end charset)
-  "Decode the text between START and END as MIME CHARSET.
-\[emu-x21.el]"
-  )
-
-(defun encode-mime-charset-string (string charset)
-  "Encode the STRING as MIME CHARSET. [emu-x21.el]"
-  string)
-
-(defun decode-mime-charset-string (string charset)
-  "Decode the STRING as MIME CHARSET. [emu-x21.el]"
-  string)
-
-
-;;; @ character
-;;;
-
-(defun char-charset (chr)
-  "Return the character set of char CHR.
-\[emu-e19.el; XEmacs 20 emulating function]"
-  (if (< chr 128)
-      charset-ascii
-    charset-latin-iso8859-1))
-
-(defun char-bytes (char)
-  "Return number of bytes a character in CHAR occupies in a buffer.
-\[emu-e19.el; MULE emulating function]"
-  1)
-
-(defalias 'char-length 'char-bytes)
-
-(defun char-columns (character)
-  "Return number of columns a CHARACTER occupies when displayed.
-\[emu-x21.el]"
-  1)
-
-;;; @@ for old MULE emulation
-;;;
-
-(defalias 'char-width 'char-columns)
-
-(defalias 'char-leading-char 'char-charset)
-
-
-;;; @ string
-;;;
-
-(defalias 'string-columns 'length)
-
-(defun string-to-char-list (str)
-  (mapcar (function identity) str)
-  )
-
-(defalias 'string-to-int-list 'string-to-char-list)
-
-(defalias 'sref 'aref)
-
-(defun truncate-string (str width &optional start-column)
-  "Truncate STR to fit in WIDTH columns.
-Optional non-nil arg START-COLUMN specifies the starting column.
-\[emu-x21.el; MULE 2.3 emulating function]"
-  (or start-column
-      (setq start-column 0))
-  (substring str start-column width)
-  )
-
-;;; @@ for old MULE emulation
-;;;
-
-(defalias 'string-width 'length)
-
-
-;;; @ end
-;;;
-
-(provide 'emu-x21)
-
-;;; emu-x21.el ends here

file-detect.el

-;;; file-detect.el --- Path management or file detection utility
-
-;; Copyright (C) 1996,1997 Free Software Foundation, Inc.
-
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id$
-;; Keywords: file detection, install, module
-;; Status: obsoleted
-
-;; This file is part of APEL (A Portable Emacs Library).
-
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
-
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;; Commentary:
-
-;;	This file is existed only for compatibility.  Please use
-;;	path-util.el instead of this file.
-
-;;; Code:
-
-(require 'path-util)
-
-(provide 'file-detect)
-
-;;; file-detect.el ends here
 
 ;;; Code:
 
-(require 'emu)
-(require 'cl)
+(require 'emu)				; for backward compatibility.
+(require 'poe)				; functionp.
+(require 'poem)				; char-int, and char-length.
+(require 'path-util)
 
 (defsubst poly-funcall (functions argument)
   "Apply initial ARGUMENT to sequence of FUNCTIONS.
 \"100\"."
   (while functions
     (setq argument (funcall (car functions) argument)
-	  functions (cdr functions))
-    )
+	  functions (cdr functions)))
   argument)
 
 
   '(((?\  ?\t) . "_")
     ((?! ?\" ?# ?$ ?% ?& ?' ?\( ?\) ?* ?/
 	 ?: ?\; ?< ?> ?? ?\[ ?\\ ?\] ?` ?{ ?| ?}) . "_")
-    (filename-control-p . "")
-    )
+    (filename-control-p . ""))
   "Alist list of characters vs. string as replacement.
 List of characters represents characters not allowed as file-name.")
 
 		   filename-maybe-truncate-by-size
 		   filename-eliminate-bottom-low-lines
 		   )))
-    (require 'path-util)
     (if (exec-installed-p "kakasi")
 	(cons 'filename-japanese-to-roman-string filters)
       filters))
     (set-buffer (get-buffer-create " *temp kakasi*"))
     (erase-buffer)
     (insert str)
-    (call-process-region (point-min)(point-max) "kakasi" t t t
-			 "-Ha" "-Ka" "-Ja" "-Ea" "-ka")
-    (buffer-string)
-    ))
+    (call-process-region
+     (point-min)(point-max)
+     "kakasi" t t t "-Ha" "-Ka" "-Ja" "-Ea" "-ka")
+    (buffer-string)))
 
 (defun filename-control-p (character)
   (let ((code (char-int character)))
-    (or (< code 32)(= code 127))
-    ))
+    (or (< code 32)(= code 127))))
 
 (defun filename-special-filter (string)
-  (let (dest
-	(i 0)
-	(len (length string))
-	(b 0)
-	)
+  (let ((len (length string))
+	(b 0)(i 0)
+	(dest ""))
     (while (< i len)
-      (let* ((chr (sref string i))
-	     (ret (assoc-if (function
-			     (lambda (key)
-			       (if (functionp key)
-				   (funcall key chr)
-				 (memq chr key)
-				 )))
-			    filename-replacement-alist))
-	     )
+      (let ((chr (sref string i))
+            (lst filename-replacement-alist)
+            ret)
+        (while (and lst (not ret))
+          (if (if (functionp (car (car lst)))
+                  (setq ret (funcall (car (car lst)) chr))
+                (setq ret (memq chr (car (car lst)))))
+              t                         ; quit this loop.
+            (setq lst (cdr lst))))
 	(if ret
-	    (setq dest (concat dest (substring string b i)(cdr ret))
+	    (setq dest (concat dest (substring string b i)(cdr (car lst)))
 		  i (+ i (char-length chr))
 		  b i)
-	  (setq i (+ i (char-length chr)))
-	  )))
-    (concat dest (substring string b))
-    ))
+	  (setq i (+ i (char-length chr))))))
+    (concat dest (substring string b))))
 
 (defun filename-eliminate-top-low-lines (string)
   (if (string-match "^_+" string)
     string))
 
 (defun filename-canonicalize-low-lines (string)
-  (let (dest)
+  (let ((dest ""))
     (while (string-match "__+" string)
       (setq dest (concat dest (substring string 0 (1+ (match-beginning 0)))))
-      (setq string (substring string (match-end 0)))
-      )
-    (concat dest string)
-    ))
+      (setq string (substring string (match-end 0))))
+    (concat dest string)))
 
 (defun filename-maybe-truncate-by-size (string)
   (if (and (> (length string) filename-limit-length)
-	   (string-match "_" string filename-limit-length)
-	   )
+	   (string-match "_" string filename-limit-length))
       (substring string 0 (match-beginning 0))
     string))
 
 It refers variable `filename-filters' and default filters refers
 `filename-limit-length', `filename-replacement-alist'."
   (and string
-       (poly-funcall filename-filters string)
-       ))
+       (poly-funcall filename-filters string)))
 
 
 ;;; @ end
 
 ;;; Code:
 
+;; for historical reason, we do (require 'emu) in this file.
+;; but you should do (require 'emu) explicitly if you use functions and/or
+;; variables defined in emu module.
 (require 'emu)
-(require 'path-util)
+(require 'path-util)			; default-load-path
+
+;; verbatim copy of `defun-maybe' from poe.el, and
+;; `make-directory-internal' and `make-directory' from poe-18.el
+(defmacro defun-maybe (name &rest everything-else)
+  "Define NAME as a function if NAME is not defined.
+See also the function `defun'."
+  (or (and (fboundp name)
+	   (not (get name 'defun-maybe)))
+      (` (or (fboundp (quote (, name)))
+	     (prog1
+		 (defun (, name) (,@ everything-else))
+	       (put (quote (, name)) 'defun-maybe t))))))
+
+(defun-maybe make-directory-internal (dirname)
+  "Create a directory. One argument, a file name string."
+  (let ((dir (expand-file-name dirname)))
+    (if (file-exists-p dir)
+	(error "Creating directory: %s is already exist" dir)
+      (call-process "mkdir" nil nil nil dir))))
+
+(defun-maybe make-directory (dir &optional parents)
+  "Create the directory DIR and any nonexistent parent dirs.
+The second (optional) argument PARENTS says whether
+to create parent directories if they don't exist."
+  (let ((len (length dir))
+	(p 0) p1 path)
+    (catch 'tag
+      (while (and (< p len) (string-match "[^/]*/?" dir p))
+	(setq p1 (match-end 0))
+	(if (= p1 len)
+	    (throw 'tag nil))
+	(setq path (substring dir 0 p1))
+	(if (not (file-directory-p path))
+	    (cond ((file-exists-p path)
+		   (error "Creating directory: %s is not directory" path))
+		  ((null parents)
+		   (error "Creating directory: %s is not exist" path))
+		  (t
+		   (make-directory-internal path))))
+	(setq p p1)))
+    (make-directory-internal dir)))
 
 
 ;;; @ compile Emacs Lisp files
 (defun compile-elisp-module (module &optional path every-time)
   (setq module (expand-file-name (symbol-name module) path))
   (let ((el-file (concat module ".el"))
-	(elc-file (concat module ".elc"))
-	)
+	(elc-file (concat module ".elc")))
     (if (or every-time
 	    (file-newer-than-file-p el-file elc-file))
-	(byte-compile-file el-file)
-      )
-    ))
+	(byte-compile-file el-file))))
 
 (defun compile-elisp-modules (modules &optional path every-time)
   (mapcar (function
 	   (lambda (module)
-	     (compile-elisp-module module path every-time)
-	     ))
+	     (compile-elisp-module module path every-time)))
 	  modules))
 
 
       (if (file-exists-p src-file)
 	  (let ((full-path (expand-file-name file dest)))
 	    (if (and (file-exists-p full-path) overwrite)
-		(delete-file full-path)
-	      )
+		(delete-file full-path))
 	    (copy-file src-file full-path t t)
 	    (if move
 		(catch 'tag
 		    (condition-case err
 			(progn
 			  (delete-file src-file)
-			  (throw 'tag nil)
-			  )
-		      (error (princ (format "%s\n" (nth 1 err))))
-		      ))))
-	    (princ (format "%s -> %s\n" file dest))
-	    ))
-      )))
+			  (throw 'tag nil))
+		      (error (princ (format "%s\n" (nth 1 err))))))))
+	    (princ (format "%s -> %s\n" file dest)))))))
 
 (defun install-files (files src dest &optional move overwrite just-print)
   (or (file-exists-p dest)
-      (make-directory dest t)
-      )
-  (mapcar (function (lambda (file)
-		      (install-file file src dest move overwrite just-print)
-		      ))
+      (make-directory dest t))
+  (mapcar (function
+	   (lambda (file)
+	     (install-file file src dest move overwrite just-print)))
 	  files))
 
 
   (let (el-file elc-file)
     (let ((name (symbol-name module)))
       (setq el-file (concat name ".el"))
-      (setq elc-file (concat name ".elc"))
-      )
+      (setq elc-file (concat name ".elc")))
     (let ((src-file (expand-file-name el-file src)))
       (if (not (file-exists-p src-file))
 	  nil 
 	    (princ (format "%s -> %s\n" el-file dest))
 	  (let ((full-path (expand-file-name el-file dest)))
 	    (if (file-exists-p full-path)
-		(delete-file full-path)
-	      )
+		(delete-file full-path))
 	    (copy-file src-file full-path t t)
-	    (princ (format "%s -> %s\n" el-file dest))
-	    )))
+	    (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 
 	    (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)
-              )
+                (delete-file full-path))
 	    (copy-file src-file full-path t t)
 	    (catch 'tag
 	      (while (file-exists-p src-file)
 		(condition-case err
 		    (progn
 		      (delete-file src-file)
-		      (throw 'tag nil)
-		      )
-		  (error (princ (format "%s\n" (nth 1 err))))
-		  )))
-	    (princ (format "%s -> %s\n" elc-file dest))
-	    )))
-      )))
+		      (throw 'tag nil))
+		  (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)
-      (make-directory dest t)
-      )
-  (mapcar (function (lambda (module)
-		      (install-elisp-module module src dest just-print)
-		      ))
+      (make-directory dest t))
+  (mapcar (function
+	   (lambda (module)
+	     (install-elisp-module module src dest just-print)))
 	  modules))
 
 
 
 ;; install to shared directory (maybe "/usr/local")
 (defvar install-prefix
-  (if (or running-emacs-18 running-xemacs
+  (if (or (<= emacs-major-version 18)	; running-emacs-18
+	  (featurep 'xemacs)		; running-xemacs
 	  (and (boundp 'system-configuration-options) ; 19.29 or later
 	       (string= system-configuration-options "NT"))) ; for Meadow
       (expand-file-name "../../.." exec-directory)
 (defun install-detect-elisp-directory (&optional prefix elisp-prefix
 						 allow-version-specific)
   (or prefix
-      (setq prefix install-prefix)
-      )
+      (setq prefix install-prefix))
   (or elisp-prefix
-      (setq elisp-prefix install-elisp-prefix)
-      )
+      (setq elisp-prefix install-elisp-prefix))
   (or
    (catch 'tag
      (let ((rest default-load-path)
 	   (pat (concat "^"
 			(expand-file-name (concat ".*/" elisp-prefix) prefix)
-			"/?$"))
-	   dir)
-       (while (setq dir (car rest))
-	 (if (string-match pat dir)
+			"/?$")))
+       (while rest
+	 (if (string-match pat (car rest))
 	     (if (or allow-version-specific
 		     (not (string-match (format "/%d\\.%d"
 						emacs-major-version
-						emacs-minor-version) dir))
-		     )
-		 (throw 'tag dir)
-	       ))
-	 (setq rest (cdr rest))
-	 )))
+						emacs-minor-version)
+					(car rest))))
+		 (throw 'tag (car rest))))
+	 (setq rest (cdr rest)))))
    (expand-file-name (concat
-		      (if running-emacs-19_29-or-later
+		      (if (and		; running-emacs-19_29-or-later
+			   (not (featurep 'xemacs))
+			   (or (>= emacs-major-version 20)
+			       (and (= emacs-major-version 19)
+				    (>= emacs-minor-version 29))))
 			  "share/"
 			"lib/")
 		      (cond ((boundp 'NEMACS) "nemacs/")
 			    ((boundp 'MULE)   "mule/")
-			    (running-xemacs
+			    ((featurep 'xemacs)	; running-xemacs
 			     (if (featurep 'mule)
 				 "xmule/"
 			       "xemacs/"))
 			    (t "emacs/"))
-		      elisp-prefix) prefix)
-   ))
+		      elisp-prefix)
+		     prefix)))
 
 (defvar install-default-elisp-directory
   (install-detect-elisp-directory))
 ;;; mcharset.el --- MIME charset API
 
-;; Copyright (C) 1997,1998 Free Software Foundation, Inc.
+;; Copyright (C) 1997,1998,1999 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).
 ;;; Code:
 
 (require 'poe)
+(require 'pcustom)
 
 (cond ((featurep 'mule)
        (cond ((featurep 'xemacs)
        (require 'mcs-ltn1)
        ))
 
+(defcustom default-mime-charset-for-write
+  (if (and (fboundp 'find-coding-system)
+	   (find-coding-system 'utf-8))
+      'utf-8
+    default-mime-charset)
+  "Default value of MIME-charset for encoding.
+It may be used when suitable MIME-charset is not found.
+It must be symbol."
+  :group 'i18n
+  :type 'mime-charset)
+
+(defcustom default-mime-charset-detect-method-for-write
+  nil
+  "Function called when suitable MIME-charset is not found to encode.
+It must be nil or function.
+If it is nil, variable `default-mime-charset-for-write' is used.
+If it is a function, interface must be (TYPE CHARSETS &rest ARGS).
+CHARSETS is list of charset.
+If TYPE is 'region, ARGS has START and END."
+  :group 'i18n
+  :type '(choice function (const nil)))
 
 (defun charsets-to-mime-charset (charsets)
   "Return MIME charset from list of charset CHARSETS.
 	    (setq rest (cdr rest)))
 	  ))))
 
+(defun find-mime-charset-by-charsets (charsets &optional mode &rest args)
+  "Like `charsets-to-mime-charset', but it does not return nil.
+
+When suitable mime-charset is not found and variable
+`default-mime-charset-detect-method-for-write' is not nil,
+`find-mime-charset-by-charsets' calls the variable as function and
+return the return value of the function.
+Interface of the function is (MODE CHARSETS &rest ARGS).
+
+When suitable mime-charset is not found and variable
+`default-mime-charset-detect-method-for-write' is nil,
+variable `default-mime-charset-for-write' is returned."
+  (or (charsets-to-mime-charset charsets)
+      (if default-mime-charset-detect-method-for-write
+	  (apply default-mime-charset-detect-method-for-write
+		 mode charsets args)
+	default-mime-charset-for-write)))
+
 
 ;;; @ end
 ;;;
 ;;; Code:
 
 (require 'poem)
-(require 'custom)
+(require 'pcustom)
 (eval-when-compile (require 'wid-edit))
 
 
   :group 'i18n
   :type 'mime-charset)
 
-(defcustom default-mime-charset-for-write
-  (if (find-coding-system 'utf-8)
-      'utf-8
-    default-mime-charset)
-  "Default value of MIME-charset for encoding.
-It may be used when suitable MIME-charset is not found.
-It must be symbol."
-  :group 'i18n
-  :type 'mime-charset)
-
-(defcustom default-mime-charset-detect-method-for-write
-  nil
-  "Function called when suitable MIME-charset is not found to encode.
-It must be nil or function.
-If it is nil, variable `default-mime-charset-for-write' is used.
-If it is a function, interface must be (TYPE CHARSETS &rest ARGS).
-CHARSETS is list of charset.
-If TYPE is 'region, ARGS has START and END."
-  :group 'i18n
-  :type '(choice function (const nil)))
-
 (defun detect-mime-charset-region (start end)
   "Return MIME charset for region between START and END."
-  (let ((charsets (find-charset-region start end)))
-    (or (charsets-to-mime-charset charsets)
-	(if default-mime-charset-detect-method-for-write
-	    (funcall default-mime-charset-detect-method-for-write
-		     'region charsets start end)
-	  default-mime-charset-for-write)
-	)))
+  (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)
 
 ;;; Code:
 
-(require 'emu)
+(require 'emu)				; for backward compatibility.
+(require 'poe)				; char-after.
+(require 'poem)				; charset-chars, char-charset,
+					; and split-char.
 
 (defun mule-caesar-region (start end &optional stride-ascii)
   "Caesar rotation of current region.
 (apel
-  (standards-version 1.0
+  (standards-version 1.1
    version VERSION
    author-version AUTHOR_VERSION
    date DATE
    build-date BUILD_DATE
    maintainer MAINTAINER
-   distribution mule
+   distribution xemacs
    priority high
    category CATEGORY
    dump nil
+;;; -*-byte-compile-dynamic: t;-*-
+;;; pces-20.el --- pces submodule for Emacs 20 and XEmacs with coding-system
+
+;; Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
+
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
+;; Keywords: emulation, compatibility, Mule
+
+;; This file is part of APEL (A Portable Emacs Library).
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;    This module requires Emacs 20.0.93, XEmacs 20.3-b5 (with mule)
+;;    or later.
+
+;;; Code:
+
+;; (defun-maybe-cond multibyte-string-p (object)
+;;   "Return t if OBJECT is a multibyte string."
+;;   ((featurep 'mule) (stringp object))
+;;   (t                nil))
+
+
+;;; @ without code-conversion
+;;;
+
+(defmacro as-binary-process (&rest body)
+  `(let (selective-display	; Disable ^M to nl translation.
+	 (coding-system-for-read  'binary)
+	 (coding-system-for-write 'binary))
+     ,@body))
+
+(defmacro as-binary-input-file (&rest body)
+  `(let ((coding-system-for-read 'binary))
+     ,@body))
+
+(defmacro as-binary-output-file (&rest body)
+  `(let ((coding-system-for-write 'binary))
+     ,@body))
+
+(defun write-region-as-binary (start end filename
+				     &optional append visit lockname)
+  "Like `write-region', q.v., but don't encode."
+  (let ((coding-system-for-write 'binary)
+	jka-compr-compression-info-list jam-zcat-filename-list)
+    (write-region start end filename append visit lockname)))
+
+(require 'broken)
+
+(broken-facility insert-file-contents-literally-treats-binary
+  "Function `insert-file-contents-literally' decodes text."
+  (let* ((str "\r\n")
+	 (coding-system-for-write 'binary)
+	 (coding-system-for-read 'raw-text-dos)
+         ;; (default-enable-multibyte-characters (multibyte-string-p str))
+	 )
+    (with-temp-buffer
+      (insert str)
+      (write-region (point-min)(point-max) "literal-test-file")
+      )
+    (string=
+     (with-temp-buffer
+       (let (file-name-handler-alist)
+	 (insert-file-contents-literally "literal-test-file")
+	 )
+       (buffer-string)
+       )
+     str)))
+
+(broken-facility insert-file-contents-literally-treats-file-name-handler
+  "Function `insert-file-contents' doesn't call file-name-handler."
+  (let (called)
+    (with-temp-buffer
+      (let ((file-name-handler-alist
+	     '(("literal-test-file" . (lambda (operation &rest args)
+					(setq called t)
+					(let (file-name-handler-alist)
+					  (apply operation args)
+					  ))))))
+	(insert-file-contents-literally "literal-test-file")
+	)
+      (delete-file "literal-test-file")
+      )
+    called))
+
+(static-if
+    (or (broken-p 'insert-file-contents-literally-treats-binary)
+	(broken-p 'insert-file-contents-literally-treats-file-name-handler))
+    (defun insert-file-contents-as-binary (filename
+					   &optional visit beg end replace)
+      "Like `insert-file-contents', but only reads in the file literally.
+A buffer may be modified in several ways after reading into the buffer,
+to Emacs features such as format decoding, character code
+conversion, find-file-hooks, automatic uncompression, etc.
+
+This function ensures that none of these modifications will take place."
+      (let ((format-alist nil)
+	    (after-insert-file-functions nil)
+	    (coding-system-for-read 'binary)
+	    (coding-system-for-write 'binary)
+	    (jka-compr-compression-info-list nil)
+	    (jam-zcat-filename-list nil)
+	    (find-buffer-file-type-function
+	     (if (fboundp 'find-buffer-file-type)
+		 (symbol-function 'find-buffer-file-type)
+	       nil)))
+	(unwind-protect
+	    (progn
+	      (fset 'find-buffer-file-type (lambda (filename) t))
+	      (insert-file-contents filename visit beg end replace))
+	  (if find-buffer-file-type-function
+	      (fset 'find-buffer-file-type find-buffer-file-type-function)
+	    (fmakunbound 'find-buffer-file-type)))))
+  (defalias 'insert-file-contents-as-binary 'insert-file-contents-literally)
+  )
+
+(defun insert-file-contents-as-raw-text (filename
+					 &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but don't code and format conversion.
+Like `insert-file-contents-literary', but it allows find-file-hooks,
+automatic uncompression, etc.
+Like `insert-file-contents-as-binary', but it converts line-break
+code."
+  (let ((coding-system-for-read 'raw-text)
+	format-alist)
+    ;; Returns list of absolute file name and length of data inserted.
+    (insert-file-contents filename visit beg end replace)))
+
+(defun insert-file-contents-as-raw-text-CRLF (filename
+					      &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but don't code and format conversion.
+Like `insert-file-contents-literary', but it allows find-file-hooks,
+automatic uncompression, etc.
+Like `insert-file-contents-as-binary', but it converts line-break code
+from CRLF to LF."
+  (let ((coding-system-for-read 'raw-text-dos)
+	format-alist)
+    ;; Returns list of absolute file name and length of data inserted.
+    (insert-file-contents filename visit beg end replace)))
+
+(defun write-region-as-raw-text-CRLF (start end filename
+					    &optional append visit lockname)
+  "Like `write-region', q.v., but write as network representation."
+  (let ((coding-system-for-write 'raw-text-dos))
+    (write-region start end filename append visit lockname)))
+
+(defun find-file-noselect-as-binary (filename &optional nowarn rawfile)
+  "Like `find-file-noselect', q.v., but don't code and format conversion."
+  (let ((coding-system-for-read 'binary)
+	format-alist)
+    (find-file-noselect filename nowarn rawfile)))
+
+(defun find-file-noselect-as-raw-text (filename &optional nowarn rawfile)
+  "Like `find-file-noselect', q.v., but it does not code and format conversion
+except for line-break code."
+  (let ((coding-system-for-read 'raw-text)
+	format-alist)
+    (find-file-noselect filename nowarn rawfile)))
+
+(defun find-file-noselect-as-raw-text-CRLF (filename &optional nowarn rawfile)
+  "Like `find-file-noselect', q.v., but it does not code and format conversion
+except for line-break code."
+  (let ((coding-system-for-read 'raw-text-dos)
+	format-alist)
+    (find-file-noselect filename nowarn rawfile)))
+
+(defun save-buffer-as-binary (&optional args)
+  "Like `save-buffer', q.v., but don't encode."
+  (let ((coding-system-for-write 'binary))
+    (save-buffer args)))
+
+(defun save-buffer-as-raw-text-CRLF (&optional args)
+  "Like `save-buffer', q.v., but save as network representation."
+  (let ((coding-system-for-write 'raw-text-dos))
+    (save-buffer args)))
+
+(defun open-network-stream-as-binary (name buffer host service)
+  "Like `open-network-stream', q.v., but don't code conversion."
+  (let ((coding-system-for-read 'binary)
+	(coding-system-for-write 'binary))
+    (open-network-stream name buffer host service)))
+
+
+;;; @ with code-conversion
+;;;
+
+(defun insert-file-contents-as-coding-system
+  (coding-system filename &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but CODING-SYSTEM the first arg will
+be applied to `coding-system-for-read'."
+  (let ((coding-system-for-read coding-system)
+	format-alist)
+    (insert-file-contents filename visit beg end replace)))
+
+(defun write-region-as-coding-system
+  (coding-system start end filename &optional append visit lockname)
+  "Like `write-region', q.v., but CODING-SYSTEM the first arg will be
+applied to `coding-system-for-write'."
+  (let ((coding-system-for-write coding-system)
+	jka-compr-compression-info-list jam-zcat-filename-list)
+    (write-region start end filename append visit lockname)))
+
+(defun find-file-noselect-as-coding-system
+  (coding-system filename &optional nowarn rawfile)
+  "Like `find-file-noselect', q.v., but CODING-SYSTEM the first arg will
+be applied to `coding-system-for-read'."
+  (let ((coding-system-for-read coding-system)
+	format-alist)
+    (find-file-noselect filename nowarn rawfile)))
+
+(defun save-buffer-as-coding-system (coding-system &optional args)
+  "Like `save-buffer', q.v., but CODING-SYSTEM the first arg will be
+applied to `coding-system-for-write'."
+  (let ((coding-system-for-write coding-system))
+    (save-buffer args)))
+
+
+;;; @ end
+;;;
+
+(provide 'pces-20)
+
+;;; pces-20.el ends here
+;;; pces-raw.el --- pces submodule for emacsen without coding-system features
+
+;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
+
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
+;; Keywords: emulation, compatibility, Mule
+
+;; This file is part of APEL (A Portable Emacs Library).
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Code:
+
+;;; @ coding-system
+;;;
+
+(defun decode-coding-string (string coding-system)
+  "Decode the STRING which is encoded in CODING-SYSTEM."
+  string)
+
+(defun encode-coding-string (string coding-system)
+  "Encode the STRING as CODING-SYSTEM."
+  string)
+
+(defun decode-coding-region (start end coding-system)
+  "Decode the text between START and END which is encoded in CODING-SYSTEM."
+  0)
+
+(defun encode-coding-region (start end coding-system)
+  "Encode the text between START and END to CODING-SYSTEM."
+  0)
+
+(defun detect-coding-region (start end)
+  "Detect coding-system of the text in the region between START and END."
+  )
+
+(defun set-buffer-file-coding-system (coding-system &optional force)
+  "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM."
+  )
+
+
+;;; @ without code-conversion
+;;;
+
+(defmacro as-binary-process (&rest body)
+  (` (let (selective-display)	; Disable ^M to nl translation.
+       (,@ body))))
+
+(defmacro as-binary-input-file (&rest body)
+  (` (let ((emx-binary-mode t)) ; Stop CRLF to LF conversion in OS/2
+       (,@ body))))
+
+(defmacro as-binary-output-file (&rest body)
+  (` (let ((emx-binary-mode t)) ; Stop CRLF to LF conversion in OS/2
+       (,@ body))))
+
+(defun write-region-as-binary (start end filename
+				     &optional append visit lockname)
+  "Like `write-region', q.v., but don't code conversion."
+  (let ((emx-binary-mode t))
+    (write-region start end filename append visit lockname)))
+
+(defun insert-file-contents-as-binary (filename
+				       &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but don't code and format conversion.
+Like `insert-file-contents-literary', but it allows find-file-hooks,
+automatic uncompression, etc.
+
+Namely this function ensures that only format decoding and character
+code conversion will not take place."
+  (let ((emx-binary-mode t))
+    ;; Returns list of absolute file name and length of data inserted.
+    (insert-file-contents filename visit beg end replace)))
+
+(defun write-region-as-raw-text-CRLF (start end filename
+					    &optional append visit lockname)
+  "Like `write-region', q.v., but write as network representation."
+  (let ((the-buf (current-buffer)))
+    (with-temp-buffer
+      (insert-buffer-substring the-buf start end)
+      (goto-char (point-min))
+      (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t)
+	(replace-match "\\1\r\n"))
+      (write-region (point-min)(point-max) filename append visit lockname))))
+
+(defalias 'insert-file-contents-as-raw-text 'insert-file-contents)
+
+(defalias 'insert-file-contents-as-raw-text-CRLF 'insert-file-contents)
+
+(defun find-file-noselect-as-binary (filename &optional nowarn rawfile)
+  "Like `find-file-noselect', q.v., but don't code and format conversion."
+  (let ((emx-binary-mode t))
+    (find-file-noselect filename nowarn rawfile)))
+
+(defalias 'find-file-noselect-as-raw-text 'find-file-noselect)
+
+(defalias 'find-file-noselect-as-raw-text-CRLF 'find-file-noselect)
+
+(defun save-buffer-as-binary (&optional args)
+  "Like `save-buffer', q.v., but don't encode."
+  (let ((emx-binary-mode t))
+    (save-buffer args)))
+
+(defun save-buffer-as-raw-text-CRLF (&optional args)
+  "Like `save-buffer', q.v., but save as network representation."
+  (if (buffer-modified-p)
+      (save-restriction
+	(widen)
+	(let ((the-buf (current-buffer))
+	      (filename (buffer-file-name)))
+	  (if filename
+	      (prog1
+		  (with-temp-buffer
+		    (insert-buffer the-buf)
+		    (goto-char (point-min))
+		    (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t)
+		      (replace-match "\\1\r\n"))
+		    (setq buffer-file-name filename)
+		    (save-buffer args))
+		(set-buffer-modified-p nil)
+		(clear-visited-file-modtime)))))))
+
+(defun open-network-stream-as-binary (name buffer host service)
+  "Like `open-network-stream', q.v., but don't code conversion."
+  (let ((emx-binary-mode t))
+    (open-network-stream name buffer host service)))
+
+
+;;; @ with code-conversion (but actually it might be not done)
+;;;
+
+(defun insert-file-contents-as-coding-system
+  (coding-system filename &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but CODING-SYSTEM is used to decode."
+  (insert-file-contents filename visit beg end replace))
+
+(defun write-region-as-coding-system
+  (coding-system start end filename &optional append visit lockname)
+  "Like `write-region', q.v., but CODING-SYSTEM is used to encode."
+  (let (jka-compr-compression-info-list jam-zcat-filename-list)
+    (write-region start end filename append visit lockname)))
+
+(defun find-file-noselect-as-coding-system
+  (coding-system filename &optional nowarn rawfile)
+  "Like `find-file-noselect', q.v., CODING-SYSTEM is used to decode."
+  (find-file-noselect filename nowarn rawfile))
+
+(defun save-buffer-as-coding-system (coding-system &optional args)
+  "Like `save-buffer', q.v., CODING-SYSTEM is used to encode."
+  (save-buffer args))
+
+
+;;; @ end
+;;;
+
+(provide 'pces-raw)
+
+;;; pces-raw.el ends here
+;;; pces-xfc.el --- pces module for XEmacs with file coding
+
+;; Copyright (C) 1998,1999 Free Software Foundation, Inc.
+
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
+;; Keywords: emulation, compatibility, Mule
+
+;; This file is part of APEL (A Portable Emacs Library).
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Code:
+
+;; Redefine if -{dos|mac|unix} is not found.
+(or (find-coding-system 'raw-text-dos)
+    (copy-coding-system 'no-conversion-dos 'raw-text-dos))
+(or (find-coding-system 'raw-text-mac)
+    (copy-coding-system 'no-conversion-mac 'raw-text-mac))
+(or (find-coding-system 'raw-text-unix)
+    (copy-coding-system 'no-conversion-unix 'raw-text-unix))
+
+(if (featurep 'mule)
+    (require 'pces-xm)
+  )
+
+(require 'pces-20)
+
+
+;;; @ end
+;;;
+
+(provide 'pces-xfc)
+
+;;; pces-xfc.el ends here
+;;; pces-xm.el --- pces module for XEmacs-mule
+
+;; Copyright (C) 1998,1999 Free Software Foundation, Inc.
+
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
+;; Keywords: emulation, compatibility, Mule
+
+;; This file is part of APEL (A Portable Emacs Library).
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Code:
+
+;;; @ fix coding-system definition
+;;;
+
+;; It seems not bug, but I can not permit it...
+(and (coding-system-property 'iso-2022-jp 'input-charset-conversion)
+     (copy-coding-system 'iso-2022-7bit 'iso-2022-jp))
+
+(and (coding-system-property 'iso-2022-jp-dos 'input-charset-conversion)
+     (copy-coding-system 'iso-2022-7bit-dos 'iso-2022-jp-dos))
+
+(or (find-coding-system 'ctext-dos)
+    (make-coding-system
+     'ctext 'iso2022
+     "Coding-system used in X as Compound Text Encoding."
+     '(charset-g0 ascii charset-g1 latin-iso8859-1
+		  eol-type nil
+		  mnemonic "CText")))
+
+(or (find-coding-system 'iso-2022-jp-2-dos)
+    (make-coding-system
+     'iso-2022-jp-2 'iso2022
+     "ISO-2022 coding system using SS2 for 96-charset in 7-bit code."
+     '(charset-g0 ascii
+       charset-g2 t ;; unspecified but can be used later.
+       seven t
+       short t
+       mnemonic "ISO7/SS2"
+       eol-type nil)))
+
+(or (find-coding-system 'gb2312-dos)
+    (copy-coding-system 'cn-gb-2312-dos 'gb2312-dos))
+(or (find-coding-system 'gb2312-mac)
+    (copy-coding-system 'cn-gb-2312-mac 'gb2312-mac))
+(or (find-coding-system 'gb2312-unix)
+    (copy-coding-system 'cn-gb-2312-unix 'gb2312-unix))
+
+(or (find-coding-system 'euc-kr-dos)
+    (make-coding-system
+     'euc-kr 'iso2022
+     "Coding-system of Korean EUC (Extended Unix Code)."
+     '(charset-g0 ascii charset-g1 korean-ksc5601
+		  mnemonic "ko/EUC"
+		  eol-type nil)))
+
+
+;;; @ end
+;;;
+
+(provide 'pces-xm)
+
+;;; pces-xm.el ends here
+;;; pces.el --- Portable Character Encoding Scheme (coding-system) features
+
+;; Copyright (C) 1998,1999 Free Software Foundation, Inc.
+
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
+;; Keywords: coding-system, emulation, compatibility, Mule
+
+;; This file is part of APEL (A Portable Emacs Library).
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Code:
+
+(require 'poe)
+
+(eval-and-compile
+  (unless (fboundp 'open-network-stream)
+    (require 'tcp)))
+
+(cond ((and (featurep 'xemacs)
+	    (featurep 'file-coding))
+       (require 'pces-xfc)
+       )
+      ((featurep 'mule)
+       (if (>= emacs-major-version 20)
+	   (require 'pces-e20)
+	 ;; for MULE 1.* and 2.*
+	 (require 'pces-om)
+	 ))
+      ((boundp 'NEMACS)
+       ;; for Nemacs and Nepoch
+       (require 'pces-nemacs)
+       )
+      (t
+       (require 'pces-raw)
+       ))
+
+	 
+;;; @ end
+;;;
+
+(provide 'pces)
+
+;;; pces.el ends here
+;;; pcustom.el -- a portable custom.el.
+
+;; Copyright (C) 1999 Mikio Nakajima <minakaji@osaka.email.ne.jp>
+;; Copyright (C) 1999 Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
+
+;; Author: Mikio Nakajima <minakaji@osaka.email.ne.jp>
+;;	Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
+;; Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
+;; Keywords: emulating, custom
+
+;; This file is part of APEL (A Portable Emacs Library).
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Code:
+
+(require 'poe)
+;; If old compiler is used under v18, `eval-when-compile' and
+;; `static-if' are expanded (and evaluated) at *load-time*.
+(eval-when-compile (require 'static))
+
+;; XXX: needs better abstraction.
+(static-if (condition-case nil
+	       ;; compile-time check.
+	       ;; "new custom" requires widget library.
+	       (and (require 'widget)
+		    (require 'custom)
+		    (fboundp 'custom-declare-variable))
+	     (error nil))
+    ;; you have "new custom". no load-time check.
+    (require 'custom)
+  ;; your custom is "old custom", or you don't have custom library
+  ;; at compile-time.
+  (or (condition-case nil
+	  ;; load-time check.
+	  ;; load "custom" if exists.
+	  (and (require 'custom)
+	       (fboundp 'custom-declare-variable))
+	(error nil))
+      ;; your custom is "old custom", or you don't have custom library.
+      ;; load emulation version of "new custom".
+      (require 'tinycustom)))
+
+(provide 'pcustom)
+
+;; end of pcustom.el
 
 ;;; Commentary:
 
-;; This modules does not includes MULE related features.  MULE related
-;; features are supported by `poem'.
+;; This modules does not includes MULE related features.
+;; MULE related features are supported by `poem'.
 
 ;;; Code:
 
 (provide 'poe)
 
+(or (boundp 'current-load-list) (setq current-load-list nil))
+
+(put 'defun-maybe 'lisp-indent-function 'defun)
 (defmacro defun-maybe (name &rest everything-else)
+  "Define NAME as a function if NAME is not defined.
+See also the function `defun'."
   (or (and (fboundp name)
 	   (not (get name 'defun-maybe)))
       (` (or (fboundp (quote (, name)))
-	     (progn
-	       (defun (, name) (,@ everything-else))
-	       (put (quote (, name)) 'defun-maybe t)
-	       ))
-	 )))
+	     (prog1
+		 (defun (, name) (,@ everything-else))
+	       ;; This `defun' will be compiled to `fset', which does
+	       ;; not update `load-history'.
+	       (setq current-load-list
+		     (cons (quote (, name)) current-load-list))
+	       (put (quote (, name)) 'defun-maybe t))))))
 
+(put 'defmacro-maybe 'lisp-indent-function 'defun)
 (defmacro defmacro-maybe (name &rest everything-else)
+  "Define NAME as a macro if NAME is not defined.
+See also the function `defmacro'."
   (or (and (fboundp name)
 	   (not (get name 'defmacro-maybe)))
       (` (or (fboundp (quote (, name)))
-	     (progn
-	       (defmacro (, name) (,@ everything-else))
-	       (put (quote (, name)) 'defmacro-maybe t)
-	       ))
-	 )))
+	     (prog1
+		 (defmacro (, name) (,@ everything-else))
+	       (setq current-load-list
+		     (cons (quote (, name)) current-load-list))
+	       (put (quote (, name)) 'defmacro-maybe t))))))
 
-(defmacro-maybe defsubst (name arglist &rest body)
-  "Define an inline function.  The syntax is just like that of `defun'."
-  (cons 'defun (cons name (cons arglist body)))
-  )
-
+(put 'defsubst-maybe 'lisp-indent-function 'defun)
 (defmacro defsubst-maybe (name &rest everything-else)
+  "Define NAME as an inline function if NAME is not defined.
+See also the macro `defsubst'."
   (or (and (fboundp name)
 	   (not (get name 'defsubst-maybe)))
       (` (or (fboundp (quote (, name)))
-	     (progn
-	       (defsubst (, name) (,@ everything-else))
-	       (put (quote (, name)) 'defsubst-maybe t)
-	       ))
-	 )))
+	     (prog1
+		 (defsubst (, name) (,@ everything-else))
+	       (setq current-load-list
+		     (cons (quote (, name)) current-load-list))
+	       (put (quote (, name)) 'defsubst-maybe t))))))
 
 (defmacro defalias-maybe (symbol definition)
+  "Define SYMBOL as an alias for DEFINITION if SYMBOL is not defined.
+See also the function `defalias'."
   (setq symbol (eval symbol))
   (or (and (fboundp symbol)
 	   (not (get symbol 'defalias-maybe)))
       (` (or (fboundp (quote (, symbol)))
-	     (progn
-	       (defalias (quote (, symbol)) (, definition))
-	       (put (quote (, symbol)) 'defalias-maybe t)
-	       ))
-	 )))
-
-(put 'defun-maybe 'lisp-indent-function 'defun)
-(put 'defsubst-maybe 'lisp-indent-function 'defun)
-(put 'defmacro-maybe 'lisp-indent-function 'defun)
+	     (prog1
+		 (defalias (quote (, symbol)) (, definition))
+	       (setq current-load-list
+		     (cons (quote (, symbol)) current-load-list))
+	       (put (quote (, symbol)) 'defalias-maybe t))))))
 
 (defmacro defvar-maybe (name &rest everything-else)
+  "Define NAME as a variable if NAME is not defined.
+See also the function `defvar'."
   (or (and (boundp name)
 	   (not (get name 'defvar-maybe)))
       (` (or (boundp (quote (, name)))
-	     (progn
-	       (defvar (, name) (,@ everything-else))
-	       (put (quote (, name)) 'defvar-maybe t)
-	       ))
-	 )))
+	     (prog1
+		 (defvar (, name) (,@ everything-else))
+	       ;; byte-compiler will generate code to update
+	       ;; `load-history'.
+	       (put (quote (, name)) 'defvar-maybe t))))))
 
 (defmacro defconst-maybe (name &rest everything-else)
+  "Define NAME as a constant variable if NAME is not defined.
+See also the function `defconst'."
   (or (and (boundp name)
-	   (not (get name 'defconst-maybe))
-	   )
+	   (not (get name 'defconst-maybe)))
       (` (or (boundp (quote (, name)))
-	     (progn
-	       (defconst (, name) (,@ everything-else))
-	       (put (quote (, name)) 'defconst-maybe t)
-	       ))
-	 )))
+	     (prog1
+		 (defconst (, name) (,@ everything-else))
+	       ;; byte-compiler will generate code to update
+	       ;; `load-history'.
+	       (put (quote (, name)) 'defconst-maybe t))))))
 
 (defmacro defun-maybe-cond (name args &optional doc &rest everything-else)
   (or (stringp doc)
       (setq everything-else (cons doc everything-else)
-	    doc nil)
-      )
+	    doc nil))
   (or (and (fboundp name)
 	   (not (get name 'defun-maybe)))
       (` (or (fboundp (quote (, name)))
-	     (progn
-	       (cond (,@ (mapcar (function
-				  (lambda (case)
-				    (list (car case)
-					  (if doc
-					      (` (defun (, name) (, args)
-						   (, doc)
-						   (,@ (cdr case))))
-					    (` (defun (, name) (, args)
-						 (,@ (cdr case))))
-					    ))))
-				 everything-else)))
-	       (put (quote (, name)) 'defun-maybe t)
-	       )))))
+	     (prog1
+		 (cond
+		  (,@ (mapcar
+		       (function
+			(lambda (case)
+			  (list (car case)
+				(if doc
+				    (` (defun (, name) (, args)
+					 (, doc)
+					 (,@ (cdr case))))
+				  (` (defun (, name) (, args)
+				       (,@ (cdr case))))))))
+		       everything-else)))
+	       (setq current-load-list
+		     (cons (quote (, name)) current-load-list))
+	       (put (quote (, name)) 'defun-maybe t))))))
 
-(defsubst subr-fboundp (symbol)
+(defmacro defmacro-maybe-cond (name args &optional doc &rest everything-else)
+  (or (stringp doc)
+      (setq everything-else (cons doc everything-else)
+	    doc nil))
+  (or (and (fboundp name)
+	   (not (get name 'defmacro-maybe)))
+      (` (or (fboundp (quote (, name)))
+	     (prog1
+		 (cond
+		  (,@ (mapcar
+		       (function
+			(lambda (case)
+			  (list (car case)
+				(if doc
+				    (` (defmacro (, name) (, args)
+					 (, doc)
+					 (,@ (cdr case))))