update.
[elisp/apel.git] / emu-18.el
index b9df350..8261107 100644 (file)
--- a/emu-18.el
+++ b/emu-18.el
@@ -1,36 +1,50 @@
-;;;
-;;; emu-18.el --- Emacs 19.* emulation module for Emacs 18.*
-;;;
-;;; Copyright (C) 1995 Free Software Foundation, Inc.
-;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko
-;;;
-;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;;; Version:
-;;;    $Id: emu-18.el,v 7.10 1996/04/11 01:04:34 morioka Exp $
-;;; Keywords: emulation, compatibility
-;;;
-;;; This file is part of tl (Tiny 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.  If not, write to the Free Software
-;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-;;;
+;;; emu-18.el --- emu API implementation for Emacs 18.*
+
+;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
+
+;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Version: $Id: emu-18.el,v 7.33 1997/04/05 06:44:01 morioka Exp $
+;; Keywords: emulation, compatibility
+
+;; 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:
 
+(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)
+
+
+;;; @ for EMACS 18.55
+;;;
+
+(defvar buffer-undo-list nil)
+
+
 ;;; @ hook
 ;;;
 
-;; These function are imported from Emacs 19.28.
+;; 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.
@@ -41,7 +55,7 @@ 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.
-\[emu-18.el; Emacs 19 emulating function]"
+\[emu-18.el; EMACS 19 emulating function]"
   (or (boundp hook)
       (set hook nil)
       )
@@ -71,7 +85,7 @@ function, it is changed to a list of functions.
 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'.
-\[emu-18.el; Emacs 19 emulating function]"
+\[emu-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
@@ -92,7 +106,7 @@ list of hooks to run in HOOK, then nothing is done.  See `add-hook'.
 (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.
-\[emu-18.el; Emacs 19 emulating function]"
+\[emu-18.el; EMACS 19 emulating function]"
   (while (and list (not (equal elt (car list))))
     (setq list (cdr list)))
   list)
@@ -104,7 +118,7 @@ If the first member of LIST is ELT, deleting it is not a side effect;
 it is simply using a different list.
 Therefore, write `(setq foo (delete element foo))'
 to be sure of changing the value of `foo'.
-\[emu-18.el; Emacs 19 emulating function]"
+\[emu-18.el; EMACS 19 emulating function]"
   (if (equal elt (car list))
       (cdr list)
     (let ((rest list)
@@ -124,13 +138,13 @@ to be sure of changing the value of `foo'.
 (defun defalias (sym newdef)
   "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.
 Associates the function with the current load file, if any.
-\[emu-18.el; Emacs 19 emulating function]"
+\[emu-18.el; EMACS 19 emulating function]"
   (fset sym newdef)
   )
 
 (defun byte-code-function-p (exp)
   "T if OBJECT is a byte-compiled function object.
-\[emu-18.el; Emacs 19 emulating function]"
+\[emu-18.el; EMACS 19 emulating function]"
   (and (consp exp)
        (let* ((rest (cdr (cdr exp))) elt)
         (if (stringp (car rest))
@@ -146,13 +160,18 @@ 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)))
+  )
+
 
-;;; @ directory
+;;; @ file
 ;;;
 
 (defun make-directory-internal (dirname)
   "Create a directory. One argument, a file name string.
-\[emu-18.el; Emacs 19 emulating function]"
+\[emu-18.el; EMACS 19 emulating function]"
   (if (file-exists-p dirname)
       (error "Creating directory: %s is already exist" dirname)
     (if (not (= (call-process "mkdir" nil nil nil dirname) 0))
@@ -163,7 +182,7 @@ Associates the function with the current load file, if any.
   "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.
-\[emu-18.el; Emacs 19 emulating function]"
+\[emu-18.el; EMACS 19 emulating function]"
   (let ((len (length dir))
        (p 0) p1 path)
     (catch 'tag
@@ -189,7 +208,49 @@ to create parent directories if they don't exist.
     (make-directory-internal dir)
     ))
 
+;; Imported from files.el of EMACS 19.33.
+(defun parse-colon-path (cd-path)
+  "Explode a colon-separated list of paths into a string list."
+  (and cd-path
+       (let (cd-prefix cd-list (cd-start 0) cd-colon)
+        (setq cd-path (concat cd-path path-separator))
+        (while (setq cd-colon (string-match path-separator cd-path cd-start))
+          (setq cd-list
+                (nconc cd-list
+                       (list (if (= cd-start cd-colon)
+                                  nil
+                               (substitute-in-file-name
+                                (file-name-as-directory
+                                 (substring cd-path cd-start cd-colon)))))))
+          (setq cd-start (+ cd-colon 1)))
+        cd-list)))
+
+;; Imported from files.el of EMACS 19.33.
+(defun file-relative-name (filename &optional directory)
+  "Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
+  (setq filename (expand-file-name filename)
+       directory (file-name-as-directory (expand-file-name
+                                          (or directory default-directory))))
+  (let ((ancestor ""))
+    (while (not (string-match (concat "^" (regexp-quote directory)) filename))
+      (setq directory (file-name-directory (substring directory 0 -1))
+           ancestor (concat "../" ancestor)))
+    (concat ancestor (substring filename (match-end 0)))))
+
+(or (fboundp 'si:directory-files)
+    (fset 'si:directory-files (symbol-function 'directory-files)))
+(defun directory-files (directory &optional full match nosort)
+  "Return a list of names of files in DIRECTORY.
+There are three optional arguments:
+If FULL is non-nil, return absolute file names.  Otherwise return names
+ that are relative to the specified directory.
+If MATCH is non-nil, mention only file names that match the regexp MATCH.
+If NOSORT is dummy for compatibility.
+\[emu-18.el; EMACS 19 emulating function]"
+  (si:directory-files directory full match)
+  )
 
+    
 ;;; @ mark
 ;;;
 
@@ -212,11 +273,72 @@ With optional non-nil ALL, force redisplay of all mode-lines.
   (set-buffer-modified-p (buffer-modified-p)))
 
 
+;;; @ overlay
+;;;
+
+(defun overlay-buffer (overlay))
+
+
 ;;; @ text property
 ;;;
 
-(defun tl:set-text-properties (start end props &optional object))
-(defun tl:overlay-buffer (overlay))
+(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)
+    ))
 
 
 ;;; @ mouse