* EMU-ELS (pccl-modules): Always install 'pccl.
[elisp/apel.git] / poe-18.el
index 4c4a830..f816d57 100644 (file)
--- a/poe-18.el
+++ b/poe-18.el
 
 ;;; Code:
 
-(autoload 'setenv "env"
-  "Set the value of the environment variable named VARIABLE to VALUE.
-VARIABLE should be a string.  VALUE is optional; if not provided or is
-`nil', the environment variable VARIABLE will be removed.  
-This function works by modifying `process-environment'."
-  t)
-
-(defvar data-directory exec-directory)
+(defvar-maybe data-directory exec-directory)
 
 
 ;;; @ for EMACS 18.55
 ;;;
 
-(defvar buffer-undo-list nil)
+(defvar-maybe buffer-undo-list nil)
 
 
-;;; @ hook
+;;; @ Lisp Language
 ;;;
 
-;; These function are imported from EMACS 19.28.
-(defun add-hook (hook function &optional append)
-  "Add to the value of HOOK the function FUNCTION.
-FUNCTION is not added if already present.
-FUNCTION is added (if necessary) at the beginning of the hook list
-unless the optional argument APPEND is non-nil, in which case
-FUNCTION is added at the end.
-HOOK should be a symbol, and FUNCTION may be any valid function.  If
-HOOK is void, it is first set to nil.  If HOOK's value is a single
-function, it is changed to a list of functions.
-\[poe-18.el; EMACS 19 emulating function]"
-  (or (boundp hook)
-      (set hook nil)
-      )
-  ;; If the hook value is a single function, turn it into a list.
-  (let ((old (symbol-value hook)))
-    (if (or (not (listp old))
-           (eq (car old) 'lambda))
-       (set hook (list old))
-      ))
-  (or (if (consp function)
-         ;; Clever way to tell whether a given lambda-expression
-         ;; is equal to anything in the hook.
-         (let ((tail (assoc (cdr function) (symbol-value hook))))
-           (equal function tail)
-           )
-       (memq function (symbol-value hook))
-       )
-      (set hook 
-          (if append
-              (nconc (symbol-value hook) (list function))
-            (cons function (symbol-value hook))
-            ))
-      ))
-
-(defun remove-hook (hook function)
-  "Remove from the value of HOOK the function FUNCTION.
-HOOK should be a symbol, and FUNCTION may be any valid function.  If
-FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
-list of hooks to run in HOOK, then nothing is done.  See `add-hook'.
-\[poe-18.el; EMACS 19 emulating function]"
-  (if (or (not (boundp hook))          ;unbound symbol, or
-         (null (symbol-value hook))    ;value is nil, or
-         (null function))              ;function is nil, then
-      nil                              ;Do nothing.
-    (let ((hook-value (symbol-value hook)))
-      (if (consp hook-value)
-         (setq hook-value (delete function hook-value))
-       (if (equal hook-value function)
-           (setq hook-value nil)
-         ))
-      (set hook hook-value)
-      )))
-
-
-;;; @ list
+;;; @@ list
 ;;;
 
-(defun member (elt list)
-  "Return non-nil if ELT is an element of LIST.  Comparison done with EQUAL.
-The value is actually the tail of LIST whose car is ELT.
-\[poe-18.el; EMACS 19 emulating function]"
-  (while (and list (not (equal elt (car list))))
-    (setq list (cdr list)))
-  list)
-
 (defun delete (elt list)
   "Delete by side effect any occurrences of ELT as a member of LIST.
 The modified LIST is returned.  Comparison is done with `equal'.
@@ -130,8 +59,27 @@ to be sure of changing the value of `foo'.
       (rplacd rest (cdr rrest))
       list)))
 
+(defun member (elt list)
+  "Return non-nil if ELT is an element of LIST.  Comparison done with EQUAL.
+The value is actually the tail of LIST whose car is ELT.
+\[poe-18.el; EMACS 19 emulating function]"
+  (while (and list (not (equal elt (car list))))
+    (setq list (cdr list)))
+  list)
+
 
-;;; @ function
+;;; @@ environment variable
+;;;
+
+(autoload 'setenv "env"
+  "Set the value of the environment variable named VARIABLE to VALUE.
+VARIABLE should be a string.  VALUE is optional; if not provided or is
+`nil', the environment variable VARIABLE will be removed.  
+This function works by modifying `process-environment'."
+  t)
+
+
+;;; @@ function
 ;;;
 
 (defun defalias (sym newdef)
@@ -141,6 +89,20 @@ Associates the function with the current load file, if any.
   (fset sym newdef)
   )
 
+
+;;; @ Compilation Features
+;;;
+
+(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)))
+  )
+
+(defmacro-maybe eval-and-compile (&rest body)
+  "Like `progn', but evaluates the body at compile time and at load time."
+  ;; Remember, it's magic.
+  (cons 'progn body))
+
 (defun byte-code-function-p (exp)
   "T if OBJECT is a byte-compiled function object.
 \[poe-18.el; EMACS 19 emulating function]"
@@ -159,11 +121,6 @@ Associates the function with the current load file, if any.
             ))
         )))
 
-(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)))
-  )
-
 (defun-maybe make-obsolete (fn new)
   "Make the byte-compiler warn that FUNCTION is obsolete.
 The warning will say that NEW should be used instead.
@@ -177,6 +134,14 @@ If NEW is a string, that is the `use instead' message."
   fn)
 
 
+;;; @ text property
+;;;
+
+(defun set-text-properties (start end properties &optional object))
+
+(defun remove-text-properties (start end properties &optional object))
+
+
 ;;; @ file
 ;;;
 
@@ -262,17 +227,7 @@ If NOSORT is dummy for compatibility.
   )
 
     
-;;; @ mark
-;;;
-
-(or (fboundp 'si:mark)
-    (fset 'si:mark (symbol-function 'mark)))
-(defun mark (&optional force)
-  (si:mark)
-  )
-
-
-;;; @ mode-line
+;;; @ Display Features
 ;;;
 
 ;;; Imported from Emacs 19.30.
@@ -354,79 +309,6 @@ With optional non-nil ALL, force redisplay of all mode-lines.
 (defun overlay-buffer (overlay))
 
 
-;;; @ text property
-;;;
-
-(defun set-text-properties (start end properties &optional object))
-
-(defun remove-text-properties (start end properties &optional object))
-
-
-;;; @@ visible/invisible
-;;;
-
-(defmacro enable-invisible ()
-  (`
-   (progn
-     (make-local-variable 'original-selective-display)
-     (setq original-selective-display selective-display)
-     (setq selective-display t)
-     )))
-
-(defmacro end-of-invisible ()
-  (` (setq selective-display
-          (if (boundp 'original-selective-display)
-              original-selective-display))
-     ))
-
-(defun invisible-region (start end)
-  (let ((buffer-read-only nil)         ;Okay even if write protected.
-       (modp (buffer-modified-p)))
-    (if (save-excursion
-         (goto-char (1- end))
-         (eq (following-char) ?\n)
-         )
-       (setq end (1- end))
-      )
-    (unwind-protect
-        (subst-char-in-region start end ?\n ?\^M t)
-      (set-buffer-modified-p modp)
-      )))
-
-(defun visible-region (start end)
-  (let ((buffer-read-only nil)         ;Okay even if write protected.
-       (modp (buffer-modified-p)))
-    (unwind-protect
-        (subst-char-in-region start end ?\^M ?\n t)
-      (set-buffer-modified-p modp)
-      )))
-
-(defun invisible-p (pos)
-  (save-excursion
-    (goto-char pos)
-    (eq (following-char) ?\^M)
-    ))
-
-(defun next-visible-point (pos)
-  (save-excursion
-    (goto-char pos)
-    (end-of-line)
-    (if (eq (following-char) ?\n)
-       (forward-char)
-      )
-    (point)
-    ))
-
-
-;;; @ string
-;;;
-
-(defun char-list-to-string (char-list)
-  "Convert list of character CHAR-LIST to string. [poe-18.el]"
-  (mapconcat (function char-to-string) char-list "")
-  )
-
-
 ;;; @ buffer
 ;;;
 
@@ -445,6 +327,71 @@ even if a buffer with that name exists."
        new)
     name))
 
+(or (fboundp 'si:mark)
+    (fset 'si:mark (symbol-function 'mark)))
+(defun mark (&optional force)
+  (si:mark)
+  )
+
+
+;;; @ hook
+;;;
+
+;; These function are imported from EMACS 19.28.
+(defun add-hook (hook function &optional append)
+  "Add to the value of HOOK the function FUNCTION.
+FUNCTION is not added if already present.
+FUNCTION is added (if necessary) at the beginning of the hook list
+unless the optional argument APPEND is non-nil, in which case
+FUNCTION is added at the end.
+HOOK should be a symbol, and FUNCTION may be any valid function.  If
+HOOK is void, it is first set to nil.  If HOOK's value is a single
+function, it is changed to a list of functions.
+\[poe-18.el; EMACS 19 emulating function]"
+  (or (boundp hook)
+      (set hook nil)
+      )
+  ;; If the hook value is a single function, turn it into a list.
+  (let ((old (symbol-value hook)))
+    (if (or (not (listp old))
+           (eq (car old) 'lambda))
+       (set hook (list old))
+      ))
+  (or (if (consp function)
+         ;; Clever way to tell whether a given lambda-expression
+         ;; is equal to anything in the hook.
+         (let ((tail (assoc (cdr function) (symbol-value hook))))
+           (equal function tail)
+           )
+       (memq function (symbol-value hook))
+       )
+      (set hook 
+          (if append
+              (nconc (symbol-value hook) (list function))
+            (cons function (symbol-value hook))
+            ))
+      ))
+
+(defun remove-hook (hook function)
+  "Remove from the value of HOOK the function FUNCTION.
+HOOK should be a symbol, and FUNCTION may be any valid function.  If
+FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
+list of hooks to run in HOOK, then nothing is done.  See `add-hook'.
+\[poe-18.el; EMACS 19 emulating function]"
+  (if (or (not (boundp hook))          ;unbound symbol, or
+         (null (symbol-value hook))    ;value is nil, or
+         (null function))              ;function is nil, then
+      nil                              ;Do nothing.
+    (let ((hook-value (symbol-value hook)))
+      (if (consp hook-value)
+         (setq hook-value (delete function hook-value))
+       (if (equal hook-value function)
+           (setq hook-value nil)
+         ))
+      (set hook hook-value)
+      )))
+
 
 ;;; @ end
 ;;;