1 ;;; poe-18.el --- poe API implementation for Emacs 18.*
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
4 ;; Copyright (C) 1999 Yuuichi Teranishi
6 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
7 ;; Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
8 ;; Yuuichi Teranishi <teranisi@gohome.org>
9 ;; Keywords: emulation, compatibility
11 ;; This file is part of APEL (A Portable Emacs Library).
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 ;; General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with this program; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
30 ;; Note to APEL developers and APEL programmers:
32 ;; If old (v18) compiler is used, top-level macros are expanded at
33 ;; *load-time*, not compile-time. Therefore,
35 ;; (1) Definitions with `*-maybe' won't be compiled.
37 ;; (2) you cannot use macros defined with `defmacro-maybe' within function
38 ;; definitions in the same file.
39 ;; (`defmacro-maybe' is evaluated at load-time, therefore byte-compiler
40 ;; treats such use of macros as (unknown) functions and compiles them
41 ;; into function calls, which will cause errors at run-time.)
43 ;; (3) `eval-when-compile' and `eval-and-compile' are evaluated at
44 ;; load-time if used at top-level.
53 (defun defalias (sym newdef)
54 "Set SYMBOL's function definition to NEWVAL, and return NEWVAL."
57 (defun byte-code-function-p (object)
58 "Return t if OBJECT is a byte-compiled function object."
59 (and (consp object) (consp (cdr object))
60 (let ((rest (cdr (cdr object)))
62 (if (stringp (car rest))
63 (setq rest (cdr rest)))
68 (eq (car elt) 'byte-code))
70 (setq rest (cdr rest)))))))
72 ;; (symbol-plist 'cyclic-function-indirection)
73 (put 'cyclic-function-indirection
75 '(cyclic-function-indirection error))
76 (put 'cyclic-function-indirection
78 "Symbol's chain of function indirections contains a loop")
80 ;; The following function definition is a direct translation of its
81 ;; C definition in emacs-20.4/src/data.c.
82 (defun indirect-function (object)
83 "Return the function at the end of OBJECT's function chain.
84 If OBJECT is a symbol, follow all function indirections and return the final
86 If OBJECT is not a symbol, just return it.
87 Signal a void-function error if the final symbol is unbound.
88 Signal a cyclic-function-indirection error if there is a loop in the
89 function chain of symbols."
94 (or (symbolp hare) (throw 'found hare))
95 (or (fboundp hare) (signal 'void-function (cons object nil)))
96 (setq hare (symbol-function hare))
97 (or (symbolp hare) (throw 'found hare))
98 (or (fboundp hare) (signal 'void-function (cons object nil)))
99 (setq hare (symbol-function hare))
101 (setq tortoise (symbol-function tortoise))
103 (if (eq hare tortoise)
104 (signal 'cyclic-function-indirection (cons object nil)))))
107 ;;; Emulate all functions and macros of emacs-20.3/lisp/byte-run.el.
108 ;;; (note: jwz's original compiler and XEmacs compiler have some more
109 ;;; macros; they are "nuked" by rms in FSF version.)
111 ;; Use `*-maybe' here because new byte-compiler may be installed.
112 (put 'inline 'lisp-indent-hook 0)
113 (defmacro-maybe inline (&rest body)
114 "Eval BODY forms sequentially and return value of last one.
116 This emulating macro does not support function inlining because old \(v18\)
117 compiler does not support inlining feature."
120 (put 'defsubst 'lisp-indent-hook 'defun)
121 (put 'defsubst 'edebug-form-spec 'defun)
122 (defmacro-maybe defsubst (name arglist &rest body)
123 "Define an inline function. The syntax is just like that of `defun'.
125 This emulating macro does not support function inlining because old \(v18\)
126 compiler does not support inlining feature."
127 (cons 'defun (cons name (cons arglist body))))
129 (defun-maybe make-obsolete (fn new)
130 "Make the byte-compiler warn that FUNCTION is obsolete.
131 The warning will say that NEW should be used instead.
132 If NEW is a string, that is the `use instead' message.
134 This emulating function does nothing because old \(v18\) compiler does not
135 support this feature."
136 (interactive "aMake function obsolete: \nxObsoletion replacement: ")
139 (defun-maybe make-obsolete-variable (var new)
140 "Make the byte-compiler warn that VARIABLE is obsolete,
141 and NEW should be used instead. If NEW is a string, then that is the
142 `use instead' message.
144 This emulating function does nothing because old \(v18\) compiler does not
145 support this feature."
146 (interactive "vMake variable obsolete: \nxObsoletion replacement: ")
149 (put 'dont-compile 'lisp-indent-hook 0)
150 (defmacro-maybe dont-compile (&rest body)
151 "Like `progn', but the body always runs interpreted \(not compiled\).
152 If you think you need this, you're probably making a mistake somewhere."
153 (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
155 (put 'eval-when-compile 'lisp-indent-hook 0)
156 (defmacro-maybe eval-when-compile (&rest body)
157 "Like progn, but evaluates the body at compile-time.
159 This emulating macro does not do compile-time evaluation at all because
160 of the limitation of old \(v18\) compiler."
163 (put 'eval-and-compile 'lisp-indent-hook 0)
164 (defmacro-maybe eval-and-compile (&rest body)
165 "Like progn, but evaluates the body at compile-time as well as at load-time.
167 This emulating macro does not do compile-time evaluation at all because
168 of the limitation of old \(v18\) compiler."
172 ;;; @ C primitives emulation.
175 (defun member (elt list)
176 "Return non-nil if ELT is an element of LIST. Comparison done with EQUAL.
177 The value is actually the tail of LIST whose car is ELT."
178 (while (and list (not (equal elt (car list))))
179 (setq list (cdr list)))
182 (defun delete (elt list)
183 "Delete by side effect any occurrences of ELT as a member of LIST.
184 The modified LIST is returned. Comparison is done with `equal'.
185 If the first member of LIST is ELT, deleting it is not a side effect;
186 it is simply using a different list.
187 Therefore, write `(setq foo (delete element foo))'
188 to be sure of changing the value of `foo'."
190 (if (equal elt (car list))
194 (while (and rrest (not (equal elt (car rrest))))
197 (setcdr rest (cdr rrest))
200 (defun default-boundp (symbol)
201 "Return t if SYMBOL has a non-void default value.
202 This is the value that is seen in buffers that do not have their own values
204 (condition-case error
206 (default-value symbol)
208 (void-variable nil)))
213 (defvar current-time-world-timezones
214 '(("PST" . -800)("PDT" . -700)("MST" . -700)
215 ("MDT" . -600)("CST" . -600)("CDT" . -500)
216 ("EST" . -500)("EDT" . -400)("AST" . -400)
217 ("NST" . -330)("UT" . +000)("GMT" . +000)
218 ("BST" . +100)("MET" . +100)("EET" . +200)
219 ("JST" . +900)("GMT+1" . +100)("GMT+2" . +200)
220 ("GMT+3" . +300)("GMT+4" . +400)("GMT+5" . +500)
221 ("GMT+6" . +600)("GMT+7" . +700)("GMT+8" . +800)
222 ("GMT+9" . +900)("GMT+10" . +1000)("GMT+11" . +1100)
223 ("GMT+12" . +1200)("GMT+13" . +1300)("GMT-1" . -100)
224 ("GMT-2" . -200)("GMT-3" . -300)("GMT-4" . -400)
225 ("GMT-5" . -500)("GMT-6" . -600)("GMT-7" . -700)
226 ("GMT-8" . -800)("GMT-9" . -900)("GMT-10" . -1000)
227 ("GMT-11" . -1100) ("GMT-12" . -1200))
228 "Time differentials of timezone from GMT in +-HHMM form.
229 Used in `current-time-zone' (Emacs 19 emulating function by APEL).")
231 (defvar current-time-local-timezone nil
232 "*Local timezone name.
233 Used in `current-time-zone' (Emacs 19 emulating function by APEL).")
235 (defun set-time-zone-rule (tz)
236 "Set the local time zone using TZ, a string specifying a time zone rule.
237 If TZ is nil, use implementation-defined default time zone information.
238 If TZ is t, use Universal Time."
241 (setq current-time-local-timezone tz))
243 (setq current-time-local-timezone "GMT"))
245 (setq current-time-local-timezone
247 ;; We use `date' command to get timezone information.
248 (call-process "date" nil (current-buffer) t)
249 (goto-char (point-min))
251 "^.*\\([A-Z][A-Z][A-Z]\\([^ \n\t]*\\)\\).*$")
252 (buffer-substring (match-beginning 1)
255 (defun current-time-zone (&optional specified-time)
256 "Return the offset and name for the local time zone.
257 This returns a list of the form (OFFSET NAME).
258 OFFSET is an integer number of seconds ahead of UTC (east of Greenwich).
259 A negative value means west of Greenwich.
260 NAME is a string giving the name of the time zone.
261 Optional argument SPECIFIED-TIME is ignored in this implementation.
262 Some operating systems cannot provide all this information to Emacs;
263 in this case, `current-time-zone' returns a list containing nil for
264 the data it can't find."
265 (let ((local-timezone (or current-time-local-timezone
267 (set-time-zone-rule nil)
268 current-time-local-timezone)))
269 timezone abszone seconds)
271 (or (cdr (assoc (upcase local-timezone)
272 current-time-world-timezones))
273 ;; "+900" style or nil.
276 (if (stringp timezone)
277 (setq timezone (string-to-int timezone)))
278 ;; Taking account of minute in timezone.
280 (setq abszone (abs timezone))
281 (setq seconds (* 60 (+ (* 60 (/ abszone 100)) (% abszone 100))))
282 (list (if (< timezone 0) (- seconds) seconds)
285 (or (fboundp 'si:current-time-string)
286 (fset 'si:current-time-string (symbol-function 'current-time-string)))
287 (defun current-time-string (&optional specified-time)
288 "Return the current time, as a human-readable string.
289 Programs can use this function to decode a time,
290 since the number of columns in each field is fixed.
291 The format is `Sun Sep 16 01:03:52 1973'.
292 If an argument SPECIFIED-TIME is given, it specifies a time to format
293 instead of the current time. The argument should have the form:
296 (HIGH LOW . IGNORED).
297 Thus, you can use times obtained from `current-time'
298 and from `file-attributes'."
299 (if (null specified-time)
300 (si:current-time-string)
301 (or (consp specified-time)
302 (error "Wrong type argument %s" specified-time))
303 (let ((high (car specified-time))
304 (low (cdr specified-time))
305 (offset (or (car (current-time-zone)) 0))
306 (mdays '(31 28 31 30 31 30 31 31 30 31 30 31))
307 (mnames '("Jan" "Feb" "Mar" "Apr" "May" "Jun"
308 "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
309 (wnames '("Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"))
310 days dd yyyy lyear mm HH MM SS)
312 (setq low (car low)))
314 (error "Wrong type argument %s" high))
316 (error "Wrong type argument %s" low))
317 (setq low (+ low offset))
322 (while (or (> high 481)
329 (setq high (- high 481)
331 (if (and (zerop (% yyyy 4))
332 (or (not (zerop (% yyyy 100)))
333 (zerop (% yyyy 400))))
339 (setq high (- high 1)
341 (setq yyyy (1+ yyyy)))
343 (while (or (> high 1)
350 (setq high (- high 1)
355 (setq low (+ 65536 low)))
357 (setq lyear (and (zerop (% yyyy 4))
358 (or (not (zerop (% yyyy 100)))
359 (zerop (% yyyy 400)))))
360 (while (> (- dd (if (and lyear (= mm 1)) 29 (nth mm mdays))) 0)
361 (setq dd (- dd (if (and lyear (= mm 1)) 29 (nth mm mdays))))
363 (setq HH (/ low 3600)
367 (format "%s %s %2d %02d:%02d:%02d %4d"
369 (- (+ (* (1- yyyy) 365) (/ (1- yyyy) 400)
370 (/ (1- yyyy) 4)) (/ (1- yyyy) 100))) 7)
375 (defun current-time ()
376 "Return the current time, as the number of seconds since 1970-01-01 00:00:00.
377 The time is returned as a list of three integers. The first has the
378 most significant 16 bits of the seconds, while the second has the
379 least significant 16 bits. The third integer gives the microsecond
382 The microsecond count is zero on systems that do not provide
383 resolution finer than a second."
384 (let* ((str (current-time-string))
385 (yyyy (string-to-int (substring str 20 24)))
386 (mm (length (member (substring str 4 7)
387 '("Dec" "Nov" "Oct" "Sep" "Aug" "Jul"
388 "Jun" "May" "Apr" "Mar" "Feb" "Jan"))))
389 (dd (string-to-int (substring str 8 10)))
390 (HH (string-to-int (substring str 11 13)))
391 (MM (string-to-int (substring str 14 16)))
392 (SS (string-to-int (substring str 17 19)))
393 (offset (or (car (current-time-zone)) 0))
396 (setq ct1 0 ct2 0 i1 0 i2 0)
397 (setq year (- yyyy 1970))
405 (setq year (- yyyy 1))
406 (setq uru (- (+ (- (/ year 4) (/ year 100))
420 (setq dn (+ dd (* 31 (1- mm))))
422 (setq dn (+ (- dn (/ (+ 23 (* 4 mm)) 10))
423 (if (and (zerop (% yyyy 4))
424 (or (not (zerop (% yyyy 100)))
425 (zerop (% yyyy 400))))
437 (setq ct1 (+ (+ (+ ct1 i1) (/ ct2 65536))
438 (/ (+ (* HH 3600) (* MM 60) SS)
440 ct2 (+ (+ i2 (% ct2 65536))
441 (% (+ (* HH 3600) (* MM 60) SS)
443 (while (< (- ct2 offset) 0)
446 (setq ct2 (- ct2 offset))
452 ;;; @@ Floating point numbers.
456 "Return the absolute value of ARG."
457 (if (< arg 0) (- arg) arg))
459 ;;; @ Basic lisp subroutines.
462 (defmacro lambda (&rest cdr)
463 "Return a lambda expression.
464 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is
465 self-quoting; the result of evaluating the lambda expression is the
466 expression itself. The lambda expression may then be treated as a
467 function, i.e., stored as the function value of a symbol, passed to
468 funcall or mapcar, etc.
470 ARGS should take the same form as an argument list for a `defun'.
471 DOCSTRING is an optional documentation string.
472 If present, it should describe how to call the function.
473 But documentation strings are usually not useful in nameless functions.
474 INTERACTIVE should be a call to the function `interactive', which see.
475 It may also be omitted.
476 BODY should be a list of lisp expressions."
477 ;; Note that this definition should not use backquotes; subr.el should not
478 ;; depend on backquote.el.
479 (list 'function (cons 'lambda cdr)))
481 (defun force-mode-line-update (&optional all)
482 "Force the mode-line of the current buffer to be redisplayed.
483 With optional non-nil ALL, force redisplay of all mode-lines."
484 (if all (save-excursion (set-buffer (other-buffer))))
485 (set-buffer-modified-p (buffer-modified-p)))
487 (defalias 'set-match-data 'store-match-data)
489 (defvar save-match-data-internal)
491 ;; We use save-match-data-internal as the local variable because
492 ;; that works ok in practice (people should not use that variable elsewhere).
493 (defmacro save-match-data (&rest body)
494 "Execute the BODY forms, restoring the global value of the match data."
495 (` (let ((save-match-data-internal (match-data)))
496 (unwind-protect (progn (,@ body))
497 (set-match-data save-match-data-internal)))))
500 ;;; @ Basic editing commands.
503 ;; 18.55 does not have these variables.
504 (defvar-maybe buffer-undo-list nil
505 "List of undo entries in current buffer.
506 APEL provides this as dummy for a compatibility.")
508 (defvar-maybe auto-fill-function nil
509 "Function called (if non-nil) to perform auto-fill.
510 APEL provides this as dummy for a compatibility.")
512 (defvar-maybe unread-command-event nil
513 "APEL provides this as dummy for a compatibility.")
514 (defvar-maybe unread-command-events nil
515 "List of events to be read as the command input.
516 APEL provides this as dummy for a compatibility.")
518 ;; (defvar-maybe minibuffer-setup-hook nil
519 ;; "Normal hook run just after entry to minibuffer.")
520 ;; (defvar-maybe minibuffer-exit-hook nil
521 ;; "Normal hook run just after exit from minibuffer.")
523 (defvar-maybe minor-mode-map-alist nil
524 "Alist of keymaps to use for minor modes.
525 APEL provides this as dummy for a compatibility.")
527 (defalias 'insert-and-inherit 'insert)
528 (defalias 'insert-before-markers-and-inherit 'insert-before-markers)
529 (defalias 'number-to-string 'int-to-string)
531 (defun generate-new-buffer-name (name &optional ignore)
532 "Return a string that is the name of no existing buffer based on NAME.
533 If there is no live buffer named NAME, then return NAME.
534 Otherwise modify name by appending `<NUMBER>', incrementing NUMBER
535 until an unused name is found, and then return that name.
536 Optional second argument IGNORE specifies a name that is okay to use
537 \(if it is in the sequence to be tried\)
538 even if a buffer with that name exists."
539 (if (get-buffer name)
541 (while (get-buffer (setq new (format "%s<%d>" name n)))
546 (or (fboundp 'si:mark)
547 (fset 'si:mark (symbol-function 'mark)))
548 (defun mark (&optional force)
551 (defun-maybe window-minibuffer-p (&optional window)
552 "Return non-nil if WINDOW is a minibuffer window."
553 (eq (or window (selected-window)) (minibuffer-window)))
555 (defun-maybe window-live-p (obj)
556 "Returns t if OBJECT is a window which is currently visible."
558 (or (eq obj (minibuffer-window))
559 (eq obj (get-buffer-window (window-buffer obj))))))
561 ;; Add optinal argument `hist'
562 (or (fboundp 'si:read-from-minibuffer)
564 (fset 'si:read-from-minibuffer (symbol-function 'read-from-minibuffer))
565 (defun read-from-minibuffer (prompt &optional
566 initial-contents keymap read hist)
568 "Read a string from the minibuffer, prompting with string PROMPT.
569 If optional second arg INITIAL-CONTENTS is non-nil, it is a string
570 to be inserted into the minibuffer before reading input.
571 If INITIAL-CONTENTS is (STRING . POSITION), the initial input
572 is STRING, but point is placed at position POSITION in the minibuffer.
573 Third arg KEYMAP is a keymap to use whilst reading;
574 if omitted or nil, the default is `minibuffer-local-map'.
575 If fourth arg READ is non-nil, then interpret the result as a lisp object
576 and return that object:
577 in other words, do `(car (read-from-string INPUT-STRING))'
578 Fifth arg HIST is ignored in this implementation."
579 (si:read-from-minibuffer prompt initial-contents keymap read))))
581 ;; Add optional argument `frame'.
582 (or (fboundp 'si:get-buffer-window)
584 (fset 'si:get-buffer-window (symbol-function 'get-buffer-window))
585 (defun get-buffer-window (buffer &optional frame)
586 "Return a window currently displaying BUFFER, or nil if none.
587 Optional argument FRAME is ignored in this implementation."
588 (si:get-buffer-window buffer))))
590 (defun-maybe walk-windows (proc &optional minibuf all-frames)
591 "Cycle through all visible windows, calling PROC for each one.
592 PROC is called with a window as argument.
594 Optional second arg MINIBUF t means count the minibuffer window even
595 if not active. MINIBUF nil or omitted means count the minibuffer iff
596 it is active. MINIBUF neither t nor nil means not to count the
597 minibuffer even if it is active.
598 Optional third argument ALL-FRAMES is ignored in this implementation."
599 (if (window-minibuffer-p (selected-window))
601 (let* ((walk-windows-start (selected-window))
602 (walk-windows-current walk-windows-start))
605 (setq walk-windows-current
606 (next-window walk-windows-current minibuf))
607 (funcall proc walk-windows-current)
608 (not (eq walk-windows-current walk-windows-start))))
609 (select-window walk-windows-start))))
611 (defun buffer-disable-undo (&optional buffer)
612 "Make BUFFER stop keeping undo information.
613 No argument or nil as argument means do this for the current buffer."
614 (buffer-flush-undo (or buffer (current-buffer))))
617 ;;; @@ Frame (Emacs 18 cannot make frame)
619 ;; The following four are frequently used for manipulating the current frame.
620 ;; frame.el has `screen-width', `screen-height', `set-screen-width' and
621 ;; `set-screen-height' for backward compatibility and declare them as obsolete.
622 (defun frame-width (&optional frame)
623 "Return number of columns available for display on FRAME.
624 If FRAME is omitted, describe the currently selected frame."
627 (defun frame-height (&optional frame)
628 "Return number of lines available for display on FRAME.
629 If FRAME is omitted, describe the currently selected frame."
632 (defun set-frame-width (frame cols &optional pretend)
633 "Specify that the frame FRAME has COLS columns.
634 Optional third arg non-nil means that redisplay should use COLS columns
635 but that the idea of the actual width of the frame should not be changed."
636 (set-screen-width cols pretend))
638 (defun set-frame-height (frame lines &optional pretend)
639 "Specify that the frame FRAME has LINES lines.
640 Optional third arg non-nil means that redisplay should use LINES lines
641 but that the idea of the actual height of the frame should not be changed."
642 (set-screen-height lines pretend))
644 ;;; @@ Environment variables.
647 (autoload 'setenv "env"
648 "Set the value of the environment variable named VARIABLE to VALUE.
649 VARIABLE should be a string. VALUE is optional; if not provided or is
650 `nil', the environment variable VARIABLE will be removed.
651 This function works by modifying `process-environment'."
655 ;;; @ File input and output commands.
658 (defvar data-directory exec-directory)
660 ;; In 18.55, `call-process' does not return exit status.
661 (defun file-executable-p (filename)
662 "Return t if FILENAME can be executed by you.
663 For a directory, this means you can access files in that directory."
664 (if (file-exists-p filename)
665 (let ((process (start-process "test" nil "test" "-x" filename)))
666 (while (eq 'run (process-status process)))
667 (zerop (process-exit-status process)))))
669 (defun make-directory-internal (dirname)
670 "Create a directory. One argument, a file name string."
671 (let ((dir (expand-file-name dirname)))
672 (if (file-exists-p dir)
673 (signal 'file-already-exists
674 (list "Creating directory: %s already exists" dir))
675 (let ((exit-status (call-process "mkdir" nil nil nil dir)))
676 (if (or (and (numberp exit-status)
677 (not (zerop exit-status)))
678 (stringp exit-status))
679 (error "Create directory %s failed.")
680 ;; `make-directory' of v19 and later returns nil for success.
683 (defun make-directory (dir &optional parents)
684 "Create the directory DIR and any nonexistent parent dirs.
685 The second (optional) argument PARENTS says whether
686 to create parent directories if they don't exist."
687 (let ((len (length dir))
690 (while (and (< p len) (string-match "[^/]*/?" dir p))
691 (setq p1 (match-end 0))
694 (setq path (substring dir 0 p1))
695 (if (not (file-directory-p path))
696 (cond ((file-exists-p path)
697 (error "Creating directory: %s is not directory" path))
699 (error "Creating directory: %s is not exist" path))
701 (make-directory-internal path))))
703 (make-directory-internal dir)))
705 (defun delete-directory (directory)
706 "Delete the directory named DIRECTORY. Does not follow symlinks."
707 (let ((exit-status (call-process "rmdir" nil nil nil directory)))
708 (when (or (and (numberp exit-status) (not (zerop exit-status)))
709 (stringp exit-status))
710 (error "Delete directory %s failed."))))
712 (defun parse-colon-path (cd-path)
713 "Explode a colon-separated list of paths into a string list."
715 (let (cd-prefix cd-list (cd-start 0) cd-colon)
716 (setq cd-path (concat cd-path path-separator))
717 (while (setq cd-colon (string-match path-separator cd-path cd-start))
720 (list (if (= cd-start cd-colon)
722 (substitute-in-file-name
723 (file-name-as-directory
724 (substring cd-path cd-start cd-colon)))))))
725 (setq cd-start (+ cd-colon 1)))
728 (defun file-relative-name (filename &optional directory)
729 "Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
730 (setq filename (expand-file-name filename)
731 directory (file-name-as-directory (expand-file-name
732 (or directory default-directory))))
734 (while (not (string-match (concat "^" (regexp-quote directory)) filename))
735 (setq directory (file-name-directory (substring directory 0 -1))
736 ancestor (concat "../" ancestor)))
737 (concat ancestor (substring filename (match-end 0)))))
739 (or (fboundp 'si:directory-files)
740 (fset 'si:directory-files (symbol-function 'directory-files)))
741 (defun directory-files (directory &optional full match nosort)
742 "Return a list of names of files in DIRECTORY.
743 There are three optional arguments:
744 If FULL is non-nil, return absolute file names. Otherwise return names
745 that are relative to the specified directory.
746 If MATCH is non-nil, mention only file names that match the regexp MATCH.
747 If NOSORT is dummy for compatibility."
748 (si:directory-files directory full match))
750 (or (fboundp 'si:write-region)
751 (fset 'si:write-region (symbol-function 'write-region)))
752 (defun write-region (start end filename &optional append visit)
753 "Write current region into specified file.
754 When called from a program, requires three arguments:
755 START, END and FILENAME. START and END are normally buffer positions
756 specifying the part of the buffer to write.
757 If START is nil, that means to use the entire buffer contents.
758 If START is a string, then output that string to the file
759 instead of any buffer contents; END is ignored.
761 Optional fourth argument APPEND if non-nil means
762 append to existing file contents (if any). If it is an integer,
763 seek to that offset in the file before writing.
764 Optional fifth argument VISIT if t means
765 set the last-save-file-modtime of buffer to this file's modtime
766 and mark buffer not modified.
767 If VISIT is a string, it is a second file name;
768 the output goes to FILENAME, but the buffer is marked as visiting VISIT.
769 VISIT is also the file name to lock and unlock for clash detection.
770 If VISIT is neither t nor nil nor a string,
771 that means do not display the \"Wrote file\" message."
774 (si:write-region (point-min) (point-max) filename append visit))
778 (si:write-region (point-min) (point-max) filename append visit)))
780 (si:write-region start end filename append visit))))
784 (or (fboundp 'si:accept-process-output)
786 (fset 'si:accept-process-output (symbol-function 'accept-process-output))
787 (defun accept-process-output (&optional process timeout timeout-msecs)
788 "Allow any pending output from subprocesses to be read by Emacs.
789 It is read into the process' buffers or given to their filter functions.
790 Non-nil arg PROCESS means do not return until some output has been received
791 from PROCESS. Nil arg PROCESS means do not return until some output has
792 been received from any process.
793 TIMEOUT and TIMEOUT-MSECS are ignored in this implementation."
794 (si:accept-process-output process))))
799 ;; In Emacs 20.4, these functions are defined in src/textprop.c.
800 (defun text-properties-at (position &optional object))
801 (defun get-text-property (position prop &optional object))
802 (defun get-char-property (position prop &optional object))
803 (defun next-property-change (position &optional object limit))
804 (defun next-single-property-change (position prop &optional object limit))
805 (defun previous-property-change (position &optional object limit))
806 (defun previous-single-property-change (position prop &optional object limit))
807 (defun add-text-properties (start end properties &optional object))
808 (defun put-text-property (start end property value &optional object))
809 (defun set-text-properties (start end properties &optional object))
810 (defun remove-text-properties (start end properties &optional object))
811 (defun text-property-any (start end property value &optional object))
812 (defun text-property-not-all (start end property value &optional object))
813 ;; the following two functions are new in v20.
814 (defun next-char-property-change (position &optional object))
815 (defun previous-char-property-change (position &optional object))
816 ;; the following two functions are obsolete.
817 ;; (defun erase-text-properties (start end &optional object)
818 ;; (defun copy-text-properties (start end src pos dest &optional prop)
824 (defun overlayp (object))
825 (defun make-overlay (beg end &optional buffer front-advance rear-advance))
826 (defun move-overlay (overlay beg end &optional buffer))
827 (defun delete-overlay (overlay))
828 (defun overlay-start (overlay))
829 (defun overlay-end (overlay))
830 (defun overlay-buffer (overlay))
831 (defun overlay-properties (overlay))
832 (defun overlays-at (pos))
833 (defun overlays-in (beg end))
834 (defun next-overlay-change (pos))
835 (defun previous-overlay-change (pos))
836 (defun overlay-lists ())
837 (defun overlay-recenter (pos))
838 (defun overlay-get (overlay prop))
839 (defun overlay-put (overlay prop value))
845 (product-provide (provide 'poe-18) (require 'apel-ver))
847 ;;; poe-18.el ends here