(file-executable-p): Returns nil if the file does not exist.
[elisp/apel.git] / poe-18.el
index a7faa15..2ca24e6 100644 (file)
--- a/poe-18.el
+++ b/poe-18.el
 ;;; Commentary:
 
 ;; Note to developers:
-;; 
+;;
 ;; If old (v18) compiler is used, top-level macros are expanded at
 ;; *load-time*, not compile-time.  So, you cannot use macros defined
-;; in this file using `defmacro-maybe'.  Especially, you cannot use
-;; `eval-when-compile' and `eval-and-compile' in this file.
+;; in this file using `defmacro-maybe'.  In addition, due to this
+;; limitation, `eval-when-compile' and `eval-and-compile' provided by
+;; this file do not do compile-time evaluation at all.
 
 ;;; Code:
 
@@ -62,15 +63,16 @@ it is simply using a different list.
 Therefore, write `(setq foo (delete element foo))'
 to be sure of changing the value of `foo'.
 \[poe-18.el; EMACS 19 emulating function]"
-  (if (equal elt (car list))
-      (cdr list)
-    (let ((rest list)
-         (rrest (cdr list)))
-      (while (and rrest (not (equal elt (car rrest))))
-       (setq rest rrest
-             rrest (cdr rrest)))
-      (setcdr rest (cdr rrest))
-      list)))
+  (if list
+      (if (equal elt (car list))
+         (cdr list)
+       (let ((rest list)
+             (rrest (cdr list)))
+         (while (and rrest (not (equal elt (car rrest))))
+           (setq rest rrest
+                 rrest (cdr rrest)))
+         (setcdr rest (cdr rrest))
+         list))))
 
 (defun member (elt list)
   "Return non-nil if ELT is an element of LIST.  Comparison done with EQUAL.
@@ -102,7 +104,7 @@ for this 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.  
+`nil', the environment variable VARIABLE will be removed.
 This function works by modifying `process-environment'."
   t)
 
@@ -135,36 +137,25 @@ Associates the function with the current load file, if any."
 ;;; @ Compilation Features
 ;;;
 
-(put 'eval-when-compile 'lisp-indent-hook 0)
-(defmacro-maybe eval-when-compile (&rest body)
-  "Like progn, but evaluates the body at compile-time.
-
-This emulating macro does not work if used at top-level.
-Top-level macros are expanded at load-time.
-\[poe-18.el; EMACS 19 emulating macro]"
-  (list 'quote (eval (cons 'progn body))))
+;;; emulate all functions and macros of emacs-20.3/lisp/byte-run.el.
+;;; (note: jwz's original compiler and XEmacs compiler have some more
+;;;  macros; they are "nuked" by rms in FSF version.)
 
-(put 'eval-and-compile 'lisp-indent-hook 0)
-(defmacro-maybe eval-and-compile (&rest body)
-  "Like progn, but evaluates the body at compile-time as well as at load-time.
+(put 'inline 'lisp-indent-hook 0)
+(defmacro inline (&rest body)
+  "Eval BODY forms sequentially and return value of last one.
 
-This emulating macro does not work if used at top-level.
-Top-level macros are expanded at load-time.
+This emulating macro does not support function inlining because old \(v18\)
+compiler does not support inlining feature.
 \[poe-18.el; EMACS 19 emulating macro]"
-  ;; `form' is a parameter of `byte-compile-form'. kludge! kludge! kludge!
-  ;; this kludge prevents from evaluating `body' twice when this macro is
-  ;; expanded at load-time.
-  (if (and (boundp 'form)
-           (eq (car-safe form) 'eval-and-compile))
-      (eval (cons 'progn body)))
-  (cons 'progn body))
+  (` (progn (,@ body))))
 
 (put 'defsubst 'lisp-indent-hook 'defun)
 (put 'defsubst 'edebug-form-spec 'defun)
 (defmacro-maybe defsubst (name arglist &rest body)
   "Define an inline function.  The syntax is just like that of `defun'.
 
-This emulating macro does not support function inlining because old (v18)
+This emulating macro does not support function inlining because old \(v18\)
 compiler does not support inlining feature.
 \[poe-18.el; EMACS 19 emulating macro]"
   (cons 'defun (cons name (cons arglist body))))
@@ -174,12 +165,48 @@ compiler does not support inlining feature.
 The warning will say that NEW should be used instead.
 If NEW is a string, that is the `use instead' message.
 
-This emulating function does nothing because old (v18) compiler does not
+This emulating function does nothing because old \(v18\) compiler does not
 support this feature.
 \[poe-18.el; EMACS 19 emulating function]"
   (interactive "aMake function obsolete: \nxObsoletion replacement: ")
   fn)
 
+(defun-maybe make-obsolete-variable (var new)
+  "Make the byte-compiler warn that VARIABLE is obsolete,
+and NEW should be used instead.  If NEW is a string, then that is the
+`use instead' message.
+
+This emulating function does nothing because old \(v18\) compiler does not
+support this feature.
+\[poe-18.el; EMACS 19 emulating function]"
+  (interactive "vMake variable obsolete: \nxObsoletion replacement: ")
+  var)
+
+(put 'dont-compile 'lisp-indent-hook 0)
+(defmacro-maybe dont-compile (&rest body)
+  "Like `progn', but the body always runs interpreted \(not compiled\).
+If you think you need this, you're probably making a mistake somewhere.
+\[poe-18.el; EMACS 19 emulating macro]"
+  (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
+
+(put 'eval-when-compile 'lisp-indent-hook 0)
+(defmacro-maybe eval-when-compile (&rest body)
+  "Like progn, but evaluates the body at compile-time.
+
+This emulating macro does not do compile-time evaluation at all because
+of the limitation of old \(v18\) compiler.
+\[poe-18.el; EMACS 19 emulating macro]"
+  (cons 'progn body))
+
+(put 'eval-and-compile 'lisp-indent-hook 0)
+(defmacro-maybe eval-and-compile (&rest body)
+  "Like progn, but evaluates the body at compile-time as well as at load-time.
+
+This emulating macro does not do compile-time evaluation at all because
+of the limitation of old \(v18\) compiler.
+\[poe-18.el; EMACS 19 emulating macro]"
+  (cons 'progn body))
+
 
 ;;; @ text property
 ;;;
@@ -188,6 +215,15 @@ support this feature.
 
 (defun remove-text-properties (start end properties &optional object))
 
+(defun get-text-property (position prop &optional object))
+
+(defun add-text-properties (start end properties &optional object))
+
+(defun put-text-property (start end property value &optional object))
+
+(defun next-property-change (position &optional object limit))
+
+(defun text-properties-at (position &optional object))
 
 ;;; @ file
 ;;;
@@ -264,7 +300,16 @@ If NOSORT is dummy for compatibility.
 \[poe-18.el; EMACS 19 emulating function]"
   (si:directory-files directory full match))
 
-    
+(defun file-executable-p (filename)
+  "Return t if FILENAME can be executed by you.
+For a directory, this means you can access files in that directory.
+\[poe-18.el; EMACS 19 emulating function]"
+  (if (file-exists-p filename)
+      (let ((process (start-process "test" nil "test" "-x" filename)))
+       (while (eq 'run (process-status process)))
+       (zerop (process-exit-status process)))))
+
+
 ;;; @ Display Features
 ;;;
 
@@ -327,7 +372,7 @@ With optional non-nil ALL, force redisplay of all mode-lines.
               (set-marker (nth posto attr-value) to))
             (setcdr (nthcdr posfrom attr-value)
                     (nthcdr posto attr-value)))))
-       
+
        (defalias 'make-overlay 'cons)
 
        (defun overlay-put (overlay prop value)