(config-apel, config-apel-package): Replace "\n" in fotmat-strings
[elisp/apel.git] / poe-18.el
index 9c44895..7e344d2 100644 (file)
--- a/poe-18.el
+++ b/poe-18.el
 ;;;
 
 (defun defalias (sym newdef)
 ;;;
 
 (defun defalias (sym newdef)
-  "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.
-Associates the function with the current load file, if any."
+  "Set SYMBOL's function definition to NEWVAL, and return NEWVAL."
   (fset sym newdef))
 
 (defun byte-code-function-p (object)
   "Return t if OBJECT is a byte-compiled function object."
   (fset sym newdef))
 
 (defun byte-code-function-p (object)
   "Return t if OBJECT is a byte-compiled function object."
-  (and (consp object)
+  (and (consp object) (consp (cdr object))
        (let ((rest (cdr (cdr object)))
             elt)
         (if (stringp (car rest))
        (let ((rest (cdr (cdr object)))
             elt)
         (if (stringp (car rest))
@@ -74,7 +73,7 @@ Associates the function with the current load file, if any."
 ;; (symbol-plist 'cyclic-function-indirection)
 (put 'cyclic-function-indirection
      'error-conditions
 ;; (symbol-plist 'cyclic-function-indirection)
 (put 'cyclic-function-indirection
      'error-conditions
-     '(cyclic-function-indirection error)
+     '(cyclic-function-indirection error))
 (put 'cyclic-function-indirection
      'error-message
      "Symbol's chain of function indirections contains a loop")
 (put 'cyclic-function-indirection
      'error-message
      "Symbol's chain of function indirections contains a loop")
@@ -212,6 +211,78 @@ for this variable."
 ;;; @@ current-time.
 ;;;
 
 ;;; @@ current-time.
 ;;;
 
+(defvar current-time-world-timezones
+  '(("PST" .  -800)("PDT" .  -700)("MST" .  -700)
+    ("MDT" .  -600)("CST" .  -600)("CDT" .  -500)
+    ("EST" .  -500)("EDT" .  -400)("AST" .  -400)
+    ("NST" .  -330)("UT"  .  +000)("GMT" .  +000)
+    ("BST" .  +100)("MET" .  +100)("EET" .  +200)
+    ("JST" .  +900)("GMT+1"  .  +100)("GMT+2"  .  +200)
+    ("GMT+3"  .  +300)("GMT+4"  .  +400)("GMT+5"  .  +500)
+    ("GMT+6"  .  +600)("GMT+7"  .  +700)("GMT+8"  .  +800)
+    ("GMT+9"  .  +900)("GMT+10" . +1000)("GMT+11" . +1100)
+    ("GMT+12" . +1200)("GMT+13" . +1300)("GMT-1"  .  -100)
+    ("GMT-2"  .  -200)("GMT-3"  .  -300)("GMT-4"  .  -400)
+    ("GMT-5"  .  -500)("GMT-6"  .  -600)("GMT-7"  .  -700)
+    ("GMT-8"  .  -800)("GMT-9"  .  -900)("GMT-10" . -1000)
+    ("GMT-11" . -1100) ("GMT-12" . -1200))
+  "Time differentials of timezone from GMT in +-HHMM form.
+Used in `current-time-zone'.")
+
+(defvar current-time-local-timezone nil 
+  "*Local timezone name.
+Used in `current-time-zone'.")
+
+(defun set-time-zone-rule (tz)
+  "Set the local time zone using TZ, a string specifying a time zone rule.
+If TZ is nil, use implementation-defined default time zone information.
+If TZ is t, use Universal Time."
+  (cond
+   ((stringp tz)
+    (setq current-time-local-timezone tz))
+   (tz
+    (setq current-time-local-timezone "GMT"))
+   (t
+    (setq current-time-local-timezone
+         (with-temp-buffer
+           ;; We use `date' command to get timezone information.
+           (call-process "date" nil (current-buffer) t)
+           (goto-char (point-min))
+           (if (looking-at 
+                "^.*\\([A-Z][A-Z][A-Z]\\([^ \n\t]*\\)\\).*$")
+               (buffer-substring (match-beginning 1)
+                                 (match-end 1))))))))
+
+(defun current-time-zone (&optional specified-time)
+  "Return the offset and name for the local time zone.
+This returns a list of the form (OFFSET NAME).
+OFFSET is an integer number of seconds ahead of UTC (east of Greenwich).
+    A negative value means west of Greenwich.
+NAME is a string giving the name of the time zone.
+Optional argument SPECIFIED-TIME is ignored in this implementation.
+Some operating systems cannot provide all this information to Emacs;
+in this case, `current-time-zone' returns a list containing nil for
+the data it can't find."
+  (let ((local-timezone (or current-time-local-timezone
+                           (progn
+                             (set-time-zone-rule nil)
+                             current-time-local-timezone)))
+       timezone abszone seconds)
+    (setq timezone
+         (or (cdr (assoc (upcase local-timezone) 
+                         current-time-world-timezones))
+             ;; "+900" style or nil.
+             local-timezone))
+    (when timezone
+      (if (stringp timezone)
+         (setq timezone (string-to-int timezone)))
+      ;; Taking account of minute in timezone.
+      ;; HHMM -> MM
+      (setq abszone (abs timezone))
+      (setq seconds (* 60 (+ (* 60 (/ abszone 100)) (% abszone 100))))
+      (list (if (< timezone 0) (- seconds) seconds)
+           local-timezone))))
+
 (or (fboundp 'si:current-time-string)
     (fset 'si:current-time-string (symbol-function 'current-time-string)))
 (defun current-time-string (&optional specified-time)
 (or (fboundp 'si:current-time-string)
     (fset 'si:current-time-string (symbol-function 'current-time-string)))
 (defun current-time-string (&optional specified-time)
@@ -219,7 +290,7 @@ for this variable."
 Programs can use this function to decode a time,
 since the number of columns in each field is fixed.
 The format is `Sun Sep 16 01:03:52 1973'.
 Programs can use this function to decode a time,
 since the number of columns in each field is fixed.
 The format is `Sun Sep 16 01:03:52 1973'.
-If an argument is given, it specifies a time to format
+If an argument SPECIFIED-TIME is given, it specifies a time to format
 instead of the current time.  The argument should have the form:
   (HIGH . LOW)
 or the form:
 instead of the current time.  The argument should have the form:
   (HIGH . LOW)
 or the form:
@@ -232,6 +303,7 @@ and from `file-attributes'."
        (error "Wrong type argument %s" specified-time))
     (let ((high (car specified-time))
          (low  (cdr specified-time))
        (error "Wrong type argument %s" specified-time))
     (let ((high (car specified-time))
          (low  (cdr specified-time))
+         (offset (or (car (current-time-zone)) 0))
          (mdays '(31 28 31 30 31 30 31 31 30 31 30 31))
          (mnames '("Jan" "Feb" "Mar" "Apr" "May" "Jun" 
                    "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
          (mdays '(31 28 31 30 31 30 31 31 30 31 30 31))
          (mnames '("Jan" "Feb" "Mar" "Apr" "May" "Jun" 
                    "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
@@ -243,7 +315,7 @@ and from `file-attributes'."
          (error "Wrong type argument %s" high))
       (or (integerp low)
          (error "Wrong type argument %s" low))
          (error "Wrong type argument %s" high))
       (or (integerp low)
          (error "Wrong type argument %s" low))
-      (setq low (+ low 32400))
+      (setq low (+ low offset))
       (while (> low 65535)
        (setq high (1+ high)
              low (- low 65536)))
       (while (> low 65535)
        (setq high (1+ high)
              low (- low 65536)))
@@ -286,10 +358,8 @@ and from `file-attributes'."
       (setq lyear (and (zerop (% yyyy 4))
                       (or (not (zerop (% yyyy 100)))
                           (zerop (% yyyy 400)))))
       (setq lyear (and (zerop (% yyyy 4))
                       (or (not (zerop (% yyyy 100)))
                           (zerop (% yyyy 400)))))
-      (while (> (- dd (nth mm mdays)) 0)
-       (if (and (= mm 1) lyear)
-           (setq dd (- dd 29))
-         (setq dd (- dd (nth mm mdays))))
+      (while (> (- dd  (if (and lyear (= mm 1)) 29 (nth mm mdays))) 0)
+       (setq dd (- dd (if (and lyear (= mm 1)) 29 (nth mm mdays))))
        (setq mm (1+ mm)))
       (setq HH (/ low 3600)
            low (% low 3600)
        (setq mm (1+ mm)))
       (setq HH (/ low 3600)
            low (% low 3600)
@@ -321,6 +391,7 @@ resolution finer than a second."
         (HH (string-to-int (substring str 11 13)))
         (MM (string-to-int (substring str 14 16)))
         (SS (string-to-int (substring str 17 19)))
         (HH (string-to-int (substring str 11 13)))
         (MM (string-to-int (substring str 14 16)))
         (SS (string-to-int (substring str 17 19)))
+        (offset (or (car (current-time-zone)) 0))
         dn ct1 ct2 i1 i2
         year uru)
     (setq ct1 0 ct2 0 i1 0 i2 0)
         dn ct1 ct2 i1 i2
         year uru)
     (setq ct1 0 ct2 0 i1 0 i2 0)
@@ -332,8 +403,9 @@ resolution finer than a second."
       (while (> ct2 65535)
        (setq ct1 (1+ ct1)
              ct2 (- ct2 65536))))
       (while (> ct2 65535)
        (setq ct1 (1+ ct1)
              ct2 (- ct2 65536))))
-    (setq uru (- (+ (- (/ yyyy 4) (/ yyyy 100)) 
-                   (/ yyyy 400)) 477))
+    (setq year (- yyyy 1))
+    (setq uru (- (+ (- (/ year 4) (/ year 100)) 
+                   (/ year 400)) 477))
     (while (> uru 0)
       (setq uru (1- uru)
            i1 (1+ i1)
     (while (> uru 0)
       (setq uru (1- uru)
            i1 (1+ i1)
@@ -369,10 +441,10 @@ resolution finer than a second."
          ct2 (+ (+ i2 (% ct2 65536))
                 (% (+ (* HH 3600) (* MM 60) SS)
                    65536)))
          ct2 (+ (+ i2 (% ct2 65536))
                 (% (+ (* HH 3600) (* MM 60) SS)
                    65536)))
-    (while (< (- ct2 32400) 0)
+    (while (< (- ct2 offset) 0)
       (setq ct1 (1- ct1)
            ct2 (+ ct2 65536)))
       (setq ct1 (1- ct1)
            ct2 (+ ct2 65536)))
-    (setq ct2 (- ct2 32400))
+    (setq ct2 (- ct2 offset))
     (while (> ct2 65535)
       (setq ct1 (1+ ct1)
            ct2 (- ct2 65536)))
     (while (> ct2 65535)
       (setq ct1 (1+ ct1)
            ct2 (- ct2 65536)))
@@ -381,13 +453,10 @@ resolution finer than a second."
 ;;; @@ Floating point numbers.
 ;;;
 
 ;;; @@ Floating point numbers.
 ;;;
 
-(defalias 'numberp 'integerp)
-
 (defun abs (arg)
   "Return the absolute value of ARG."
   (if (< arg 0) (- arg) arg))
 
 (defun abs (arg)
   "Return the absolute value of ARG."
   (if (< arg 0) (- arg) arg))
 
-
 ;;; @ Basic lisp subroutines.
 ;;;
 
 ;;; @ Basic lisp subroutines.
 ;;;
 
@@ -416,16 +485,49 @@ With optional non-nil ALL, force redisplay of all mode-lines."
   (if all (save-excursion (set-buffer (other-buffer))))
   (set-buffer-modified-p (buffer-modified-p)))
 
   (if all (save-excursion (set-buffer (other-buffer))))
   (set-buffer-modified-p (buffer-modified-p)))
 
-;; (defalias 'save-match-data 'store-match-data)
+(defalias 'set-match-data 'store-match-data)
+
+(defvar save-match-data-internal)
+
+;; We use save-match-data-internal as the local variable because
+;; that works ok in practice (people should not use that variable elsewhere).
+(defmacro save-match-data (&rest body)
+  "Execute the BODY forms, restoring the global value of the match data."
+  (` (let ((save-match-data-internal (match-data)))
+       (unwind-protect (progn (,@ body))
+         (set-match-data save-match-data-internal)))))
 
 
 ;;; @ Basic editing commands.
 ;;;
 
 
 
 ;;; @ Basic editing commands.
 ;;;
 
-;; 18.55 does not have this variable.
-(defvar buffer-undo-list nil)
+;; 18.55 does not have these variables.
+(defvar buffer-undo-list nil
+  "List of undo entries in current buffer.
+APEL provides this as dummy for a compatibility.")
+
+(defvar auto-fill-function nil
+  "Function called (if non-nil) to perform auto-fill.
+APEL provides this as dummy for a compatibility.")
 
 
-(defalias 'buffer-disable-undo 'buffer-flush-undo)
+(defvar unread-command-event nil
+  "APEL provides this as dummy for a compatibility.")
+(defvar unread-command-events nil
+  "List of events to be read as the command input.
+APEL provides this as dummy for a compatibility.")
+
+;; (defvar minibuffer-setup-hook nil
+;;   "Normal hook run just after entry to minibuffer.")
+;; (defvar minibuffer-exit-hook nil
+;;   "Normal hook run just after exit from minibuffer.")
+
+(defvar minor-mode-map-alist nil
+  "Alist of keymaps to use for minor modes.
+APEL provides this as dummy for a compatibility.")
+
+(defalias 'insert-and-inherit 'insert)
+(defalias 'insert-before-markers-and-inherit 'insert-before-markers)
+(defalias 'number-to-string 'int-to-string)
 
 (defun generate-new-buffer-name (name &optional ignore)
   "Return a string that is the name of no existing buffer based on NAME.
 
 (defun generate-new-buffer-name (name &optional ignore)
   "Return a string that is the name of no existing buffer based on NAME.
@@ -447,6 +549,98 @@ even if a buffer with that name exists."
 (defun mark (&optional force)
   (si:mark))
 
 (defun mark (&optional force)
   (si:mark))
 
+(defun window-minibuffer-p (&optional window)
+"Return non-nil if WINDOW is a minibuffer window."
+  (eq (or window (selected-window)) (minibuffer-window)))
+
+(defun window-live-p (object)
+  "Returns t if OBJECT is a window which is currently visible."
+  (and (windowp object)
+       (or (eq object (minibuffer-window))
+          (eq object (get-buffer-window (window-buffer object))))))
+
+;; Add optinal argument `hist'
+(or (fboundp 'si:read-from-minibuffer)
+    (progn
+      (fset 'si:read-from-minibuffer (symbol-function 'read-from-minibuffer))
+      (defun read-from-minibuffer (prompt &optional
+                                         initial-contents keymap read hist)
+       
+       "Read a string from the minibuffer, prompting with string PROMPT.
+If optional second arg INITIAL-CONTENTS is non-nil, it is a string
+to be inserted into the minibuffer before reading input.
+If INITIAL-CONTENTS is (STRING . POSITION), the initial input
+is STRING, but point is placed at position POSITION in the minibuffer.
+Third arg KEYMAP is a keymap to use whilst reading;
+if omitted or nil, the default is `minibuffer-local-map'.
+If fourth arg READ is non-nil, then interpret the result as a lisp object
+and return that object:
+in other words, do `(car (read-from-string INPUT-STRING))'
+Fifth arg HIST is ignored in this implementation."
+       (si:read-from-minibuffer prompt initial-contents keymap read))))
+
+;; Add optional argument `frame'.
+(or (fboundp 'si:get-buffer-window)
+    (progn
+      (fset 'si:get-buffer-window (symbol-function 'get-buffer-window))
+      (defun get-buffer-window (buffer &optional frame)
+       "Return a window currently displaying BUFFER, or nil if none.
+Optional argument FRAME is ignored in this implementation."
+       (si:get-buffer-window buffer))))
+
+(defun walk-windows (proc &optional minibuf all-frames)
+  "Cycle through all visible windows, calling PROC for each one.
+PROC is called with a window as argument.
+
+Optional second arg MINIBUF t means count the minibuffer window even
+if not active.  MINIBUF nil or omitted means count the minibuffer iff
+it is active.  MINIBUF neither t nor nil means not to count the
+minibuffer even if it is active.
+Optional third argument ALL-FRAMES is ignored in this implementation."
+  (if (window-minibuffer-p (selected-window))
+      (setq minibuf t))
+  (let* ((walk-windows-start (selected-window))
+        (walk-windows-current walk-windows-start))
+    (unwind-protect
+       (while (progn
+                (setq walk-windows-current
+                      (next-window walk-windows-current minibuf))
+                (funcall proc walk-windows-current)
+                (not (eq walk-windows-current walk-windows-start))))
+      (select-window walk-windows-start))))
+
+(defun buffer-disable-undo (&optional buffer)
+  "Make BUFFER stop keeping undo information.
+No argument or nil as argument means do this for the current buffer."
+   (buffer-flush-undo (or buffer (current-buffer))))
+
+
+;;; @@ Frame (Emacs 18 cannot make frame)
+;;;
+;; The following four are frequently used for manipulating the current frame.
+;; frame.el has `screen-width', `screen-height', `set-screen-width' and
+;; `set-screen-height' for backward compatibility and declare them as obsolete.
+(defun frame-width (&optional frame)
+  "Return number of columns available for display on FRAME.
+If FRAME is omitted, describe the currently selected frame."
+  (screen-width))
+
+(defun frame-height (&optional frame)
+  "Return number of lines available for display on FRAME.
+If FRAME is omitted, describe the currently selected frame."
+  (screen-height))
+
+(defun set-frame-width (frame cols &optional pretend)
+  "Specify that the frame FRAME has COLS columns.
+Optional third arg non-nil means that redisplay should use COLS columns
+but that the idea of the actual width of the frame should not be changed."
+  (set-screen-width cols pretend))
+
+(defun set-frame-height (frame lines &optional pretend)
+  "Specify that the frame FRAME has LINES lines.
+Optional third arg non-nil means that redisplay should use LINES lines
+but that the idea of the actual height of the frame should not be changed."
+  (set-screen-height lines pretend))
 
 ;;; @@ Environment variables.
 ;;;
 
 ;;; @@ Environment variables.
 ;;;
@@ -540,6 +734,19 @@ If MATCH is non-nil, mention only file names that match the regexp MATCH.
 If NOSORT is dummy for compatibility."
   (si:directory-files directory full match))
 
 If NOSORT is dummy for compatibility."
   (si:directory-files directory full match))
 
+;;; @ Process.
+;;; 
+(or (fboundp 'si:accept-process-output)
+    (progn
+      (fset 'si:accept-process-output (symbol-function 'accept-process-output))
+      (defun accept-process-output (&optional process timeout timeout-msecs)
+       "Allow any pending output from subprocesses to be read by Emacs.
+It is read into the process' buffers or given to their filter functions.
+Non-nil arg PROCESS means do not return until some output has been received
+ from PROCESS. Nil arg PROCESS means do not return until some output has
+ been received from any process.
+TIMEOUT and TIMEOUT-MSECS are ignored in this implementation."
+       (si:accept-process-output process))))
 
 ;;; @ Text property.
 ;;;
 
 ;;; @ Text property.
 ;;;
@@ -553,7 +760,7 @@ If NOSORT is dummy for compatibility."
 (defun previous-property-change (position &optional object limit))
 (defun previous-single-property-change (position prop &optional object limit))
 (defun add-text-properties (start end properties &optional object))
 (defun previous-property-change (position &optional object limit))
 (defun previous-single-property-change (position prop &optional object limit))
 (defun add-text-properties (start end properties &optional object))
-(defun put-text-properties (start end property &optional object))
+(defun put-text-property (start end property value &optional object))
 (defun set-text-properties (start end properties &optional object))
 (defun remove-text-properties (start end properties &optional object))
 (defun text-property-any (start end property value &optional object))
 (defun set-text-properties (start end properties &optional object))
 (defun remove-text-properties (start end properties &optional object))
 (defun text-property-any (start end property value &optional object))
@@ -569,72 +776,27 @@ If NOSORT is dummy for compatibility."
 ;;; @ Overlay.
 ;;;
 
 ;;; @ Overlay.
 ;;;
 
-(cond
- ((boundp 'NEMACS)
-  (defvar emu:available-face-attribute-alist
-    '(
-      ;;(bold      . inversed-region)
-      (italic    . underlined-region)
-      (underline . underlined-region)))
-
-  ;; by YAMATE Keiichirou 1994/10/28
-  (defun attribute-add-narrow-attribute (attr from to)
-    (or (consp (symbol-value attr))
-       (set attr (list 1)))
-    (let* ((attr-value (symbol-value attr))
-          (len (car attr-value))
-          (posfrom 1)
-          posto)
-      (while (and (< posfrom len)
-                 (> from (nth posfrom attr-value)))
-       (setq posfrom (1+ posfrom)))
-      (setq posto posfrom)
-      (while (and (< posto len)
-                 (> to (nth posto attr-value)))
-       (setq posto (1+ posto)))
-      (if  (= posto posfrom)
-         (if (= (% posto 2) 1)
-             (if (and (< to len)
-                      (= to (nth posto attr-value)))
-                 (set-marker (nth posto attr-value) from)
-               (setcdr (nthcdr (1- posfrom) attr-value)
-                       (cons (set-marker-type (set-marker (make-marker)
-                                                          from)
-                                              'point-type)
-                             (cons (set-marker-type
-                                    (set-marker (make-marker)
-                                                to)
-                                    nil)
-                                   (nthcdr posto attr-value))))
-               (setcar attr-value (+ len 2))))
-       (if (= (% posfrom 2) 0)
-           (setq posfrom (1- posfrom))
-         (set-marker (nth posfrom attr-value) from))
-       (if (= (% posto 2) 0)
-           nil
-         (setq posto (1- posto))
-         (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)
-    (let ((ret (and (eq prop 'face)
-                   (assq value emu:available-face-attribute-alist))))
-      (if ret
-         (attribute-add-narrow-attribute (cdr ret)
-                                         (car overlay)(cdr overlay))))))
- (t
-  (defun make-overlay (beg end &optional buffer type))
-  (defun overlay-put (overlay prop value))))
-
+(defun overlayp (object))
+(defun make-overlay (beg end &optional buffer front-advance rear-advance))
+(defun move-overlay (overlay beg end &optional buffer))
+(defun delete-overlay (overlay))
+(defun overlay-start (overlay))
+(defun overlay-end (overlay))
 (defun overlay-buffer (overlay))
 (defun overlay-buffer (overlay))
-
+(defun overlay-properties (overlay))
+(defun overlays-at (pos))
+(defun overlays-in (beg end))
+(defun next-overlay-change (pos))
+(defun previous-overlay-change (pos))
+(defun overlay-lists ())
+(defun overlay-recenter (pos))
+(defun overlay-get (overlay prop))
+(defun overlay-put (overlay prop value))
 
 ;;; @ End.
 ;;;
 
 
 ;;; @ End.
 ;;;
 
-(provide 'poe-18)
+(require 'product)
+(product-provide (provide 'poe-18) (require 'apel-ver))
 
 ;;; poe-18.el ends here
 
 ;;; poe-18.el ends here