update.
[elisp/apel.git] / poe-18.el
1 ;;; poe-18.el --- poe API implementation for Emacs 18.*
2
3 ;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
4 ;; Copyright (C) 1999 Yuuichi Teranishi
5
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
10
11 ;; This file is part of APEL (A Portable Emacs Library).
12
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.
17
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.
22
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., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Commentary:
29
30 ;; Note to APEL developers and APEL programmers:
31 ;;
32 ;; If old (v18) compiler is used, top-level macros are expanded at
33 ;; *load-time*, not compile-time. Therefore,
34 ;;
35 ;; (1) Definitions with `*-maybe' won't be compiled.
36 ;;
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.)
42 ;;
43 ;; (3) `eval-when-compile' and `eval-and-compile' are evaluated at
44 ;;     load-time if used at top-level.
45
46 ;;; Code:
47
48 (require 'pym)
49
50
51 ;;; @ Compilation.
52 ;;;
53
54 (defun defalias (symbol definition)
55   "Set SYMBOL's function definition to DEFINITION, and return DEFINITION.
56 Associates the function with the current load file, if any.
57
58 This emulating function does not support load-history feature."
59   (fset symbol definition))
60
61 (defun byte-code-function-p (object)
62   "Return t if OBJECT is a byte-compiled function object."
63   (and (consp object) (consp (cdr object))
64        (let ((rest (cdr (cdr object)))
65              elt)
66          (if (stringp (car rest))
67              (setq rest (cdr rest)))
68          (catch 'tag
69            (while rest
70              (setq elt (car rest))
71              (if (and (consp elt)
72                       (eq (car elt) 'byte-code))
73                  (throw 'tag t))
74              (setq rest (cdr rest)))))))
75
76 ;; (symbol-plist 'cyclic-function-indirection)
77 (put 'cyclic-function-indirection
78      'error-conditions
79      '(cyclic-function-indirection error))
80 (put 'cyclic-function-indirection
81      'error-message
82      "Symbol's chain of function indirections contains a loop")
83
84 ;; The following function definition is a direct translation of its
85 ;; C definition in emacs-20.4/src/data.c.
86 (defun indirect-function (object)
87   "Return the function at the end of OBJECT's function chain.
88 If OBJECT is a symbol, follow all function indirections and return the final
89 function binding.
90 If OBJECT is not a symbol, just return it.
91 Signal a void-function error if the final symbol is unbound.
92 Signal a cyclic-function-indirection error if there is a loop in the
93 function chain of symbols."
94   (let* ((hare object)
95          (tortoise hare))
96     (catch 'found
97       (while t
98         (or (symbolp hare) (throw 'found hare))
99         (or (fboundp hare) (signal 'void-function (cons object nil)))
100         (setq hare (symbol-function hare))
101         (or (symbolp hare) (throw 'found hare))
102         (or (fboundp hare) (signal 'void-function (cons object nil)))
103         (setq hare (symbol-function hare))
104
105         (setq tortoise (symbol-function tortoise))
106
107         (if (eq hare tortoise)
108             (signal 'cyclic-function-indirection (cons object nil)))))
109     hare))
110
111 ;;; Emulate all functions and macros of emacs-20.3/lisp/byte-run.el.
112 ;;; (note: jwz's original compiler and XEmacs compiler have some more
113 ;;;  macros; they are "nuked" by rms in FSF version.)
114
115 ;; Use `*-maybe' here because new byte-compiler may be installed.
116 (put 'inline 'lisp-indent-hook 0)
117 (defmacro-maybe inline (&rest body)
118   "Eval BODY forms sequentially and return value of last one.
119
120 This emulating macro does not support function inlining because old \(v18\)
121 compiler does not support inlining feature."
122   (cons 'progn body))
123
124 (put 'defsubst 'lisp-indent-hook 'defun)
125 (put 'defsubst 'edebug-form-spec 'defun)
126 (defmacro-maybe defsubst (name arglist &rest body)
127   "Define an inline function.  The syntax is just like that of `defun'.
128
129 This emulating macro does not support function inlining because old \(v18\)
130 compiler does not support inlining feature."
131   (cons 'defun (cons name (cons arglist body))))
132
133 (defun-maybe make-obsolete (fn new)
134   "Make the byte-compiler warn that FUNCTION is obsolete.
135 The warning will say that NEW should be used instead.
136 If NEW is a string, that is the `use instead' message.
137
138 This emulating function does nothing because old \(v18\) compiler does not
139 support this feature."
140   (interactive "aMake function obsolete: \nxObsoletion replacement: ")
141   fn)
142
143 (defun-maybe make-obsolete-variable (var new)
144   "Make the byte-compiler warn that VARIABLE is obsolete,
145 and NEW should be used instead.  If NEW is a string, then that is the
146 `use instead' message.
147
148 This emulating function does nothing because old \(v18\) compiler does not
149 support this feature."
150   (interactive "vMake variable obsolete: \nxObsoletion replacement: ")
151   var)
152
153 (put 'dont-compile 'lisp-indent-hook 0)
154 (defmacro-maybe dont-compile (&rest body)
155   "Like `progn', but the body always runs interpreted \(not compiled\).
156 If you think you need this, you're probably making a mistake somewhere."
157   (list 'eval (list 'quote (if (cdr body) (cons 'progn body) (car body)))))
158
159 (put 'eval-when-compile 'lisp-indent-hook 0)
160 (defmacro-maybe eval-when-compile (&rest body)
161   "Like progn, but evaluates the body at compile-time.
162
163 This emulating macro does not do compile-time evaluation at all because
164 of the limitation of old \(v18\) compiler."
165   (cons 'progn body))
166
167 (put 'eval-and-compile 'lisp-indent-hook 0)
168 (defmacro-maybe eval-and-compile (&rest body)
169   "Like progn, but evaluates the body at compile-time as well as at load-time.
170
171 This emulating macro does not do compile-time evaluation at all because
172 of the limitation of old \(v18\) compiler."
173   (cons 'progn body))
174
175
176 ;;; @ C primitives emulation.
177 ;;;
178
179 (defun member (elt list)
180   "Return non-nil if ELT is an element of LIST.  Comparison done with EQUAL.
181 The value is actually the tail of LIST whose car is ELT."
182   (while (and list (not (equal elt (car list))))
183     (setq list (cdr list)))
184   list)
185
186 (defun delete (elt list)
187   "Delete by side effect any occurrences of ELT as a member of LIST.
188 The modified LIST is returned.  Comparison is done with `equal'.
189 If the first member of LIST is ELT, deleting it is not a side effect;
190 it is simply using a different list.
191 Therefore, write `(setq foo (delete element foo))'
192 to be sure of changing the value of `foo'."
193   (if list
194       (if (equal elt (car list))
195           (cdr list)
196         (let ((rest list)
197               (rrest (cdr list)))
198           (while (and rrest (not (equal elt (car rrest))))
199             (setq rest rrest
200                   rrest (cdr rrest)))
201           (setcdr rest (cdr rrest))
202           list))))
203
204 (defun default-boundp (symbol)
205   "Return t if SYMBOL has a non-void default value.
206 This is the value that is seen in buffers that do not have their own values
207 for this variable."
208   (condition-case error
209       (progn
210         (default-value symbol)
211         t)
212     (void-variable nil)))
213
214 ;;; @@ current-time.
215 ;;;
216
217 (defvar current-time-world-timezones
218   '(("PST" .  -800)("PDT" .  -700)("MST" .  -700)
219     ("MDT" .  -600)("CST" .  -600)("CDT" .  -500)
220     ("EST" .  -500)("EDT" .  -400)("AST" .  -400)
221     ("NST" .  -330)("UT"  .  +000)("GMT" .  +000)
222     ("BST" .  +100)("MET" .  +100)("EET" .  +200)
223     ("JST" .  +900)("GMT+1"  .  +100)("GMT+2"  .  +200)
224     ("GMT+3"  .  +300)("GMT+4"  .  +400)("GMT+5"  .  +500)
225     ("GMT+6"  .  +600)("GMT+7"  .  +700)("GMT+8"  .  +800)
226     ("GMT+9"  .  +900)("GMT+10" . +1000)("GMT+11" . +1100)
227     ("GMT+12" . +1200)("GMT+13" . +1300)("GMT-1"  .  -100)
228     ("GMT-2"  .  -200)("GMT-3"  .  -300)("GMT-4"  .  -400)
229     ("GMT-5"  .  -500)("GMT-6"  .  -600)("GMT-7"  .  -700)
230     ("GMT-8"  .  -800)("GMT-9"  .  -900)("GMT-10" . -1000)
231     ("GMT-11" . -1100) ("GMT-12" . -1200))
232   "Time differentials of timezone from GMT in +-HHMM form.
233 Used in `current-time-zone' (Emacs 19 emulating function in poe-18.el).")
234
235 (defvar current-time-local-timezone nil 
236   "*Local timezone name.
237 Used in `current-time-zone' (Emacs 19 emulating function in poe-18.el).")
238
239 (defun current-time-zone (&optional specified-time)
240   "Return the offset and name for the local time zone.
241 This returns a list of the form (OFFSET NAME).
242 OFFSET is an integer number of seconds ahead of UTC (east of Greenwich).
243     A negative value means west of Greenwich.
244 NAME is a string giving the name of the time zone.
245 Optional argument SPECIFIED-TIME is ignored in this implementation.
246 Some operating systems cannot provide all this information to Emacs;
247 in this case, `current-time-zone' returns a list containing nil for
248 the data it can't find."
249   (let ((local-timezone 
250          (or current-time-local-timezone
251              (setq current-time-local-timezone
252                    (with-temp-buffer
253                      (call-process "date" nil (current-buffer) t)
254                      (goto-char (point-min))
255                      (if (looking-at 
256                           "^.*\\([A-Z][A-Z][A-Z]\\([^ \n\t]*\\)\\).*$")
257                          (buffer-substring (match-beginning 1)
258                                            (match-end 1)))))))
259         timezone abszone seconds)
260     (setq timezone
261           (or (cdr (assoc (upcase local-timezone) 
262                           current-time-world-timezones))
263               ;; "+900" style or nil.
264               local-timezone))
265     (when timezone
266       (if (stringp timezone)
267           (setq timezone (string-to-int timezone)))
268       ;; Taking account of minute in timezone.
269       ;; HHMM -> MM
270       (setq abszone (abs timezone))
271       (setq seconds (* 60 (+ (* 60 (/ abszone 100)) (% abszone 100))))
272       (list (if (< timezone 0) (- seconds) seconds)
273             local-timezone))))
274
275 (or (fboundp 'si:current-time-string)
276     (fset 'si:current-time-string (symbol-function 'current-time-string)))
277 (defun current-time-string (&optional specified-time)
278   "Return the current time, as a human-readable string.
279 Programs can use this function to decode a time,
280 since the number of columns in each field is fixed.
281 The format is `Sun Sep 16 01:03:52 1973'.
282 If an argument SPECIFIED-TIME is given, it specifies a time to format
283 instead of the current time.  The argument should have the form:
284   (HIGH . LOW)
285 or the form:
286   (HIGH LOW . IGNORED).
287 Thus, you can use times obtained from `current-time'
288 and from `file-attributes'."
289   (if (null specified-time)
290       (si:current-time-string)
291     (or (consp specified-time)
292         (error "Wrong type argument %s" specified-time))
293     (let ((high (car specified-time))
294           (low  (cdr specified-time))
295           (offset (or (car (current-time-zone)) 0))
296           (mdays '(31 28 31 30 31 30 31 31 30 31 30 31))
297           (mnames '("Jan" "Feb" "Mar" "Apr" "May" "Jun" 
298                     "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
299           (wnames '("Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"))
300           days dd yyyy lyear mm HH MM SS)
301       (if (consp low)
302           (setq low (car low)))
303       (or (integerp high)
304           (error "Wrong type argument %s" high))
305       (or (integerp low)
306           (error "Wrong type argument %s" low))
307       (setq low (+ low offset))
308       (while (> low 65535)
309         (setq high (1+ high)
310               low (- low 65536)))
311       (setq yyyy 1970)
312       (while (or (> high 481)
313                  (and (= high 481)
314                       (>= low 13184)))
315         (if (and (> high 0)
316                  (< low 13184))
317             (setq high (1- high)
318                   low  (+ 65536 low)))
319         (setq high (- high 481)
320               low  (- low 13184))
321         (if (and (zerop (% yyyy 4))
322                  (or (not (zerop (% yyyy 100)))
323                      (zerop (% yyyy 400))))
324             (progn
325               (if (and (> high 0) 
326                        (< low 20864))
327                   (setq high (1- high)
328                         low  (+ 65536 low)))
329               (setq high (- high 1)
330                     low (- low 20864))))
331         (setq yyyy (1+ yyyy)))
332       (setq dd 1)
333       (while (or (> high 1)
334                  (and (= high 1)
335                       (>= low 20864)))
336         (if (and (> high 0)
337                  (< low 20864))
338             (setq high (1- high)
339                   low  (+ 65536 low)))
340         (setq high (- high 1)
341               low  (- low 20864)
342               dd (1+ dd)))
343       (setq days dd)
344       (if (= high 1)
345           (setq low (+ 65536 low)))
346       (setq mm 0)
347       (setq lyear (and (zerop (% yyyy 4))
348                        (or (not (zerop (% yyyy 100)))
349                            (zerop (% yyyy 400)))))
350       (while (> (- dd (nth mm mdays)) 0)
351         (if (and (= mm 1) lyear)
352             (setq dd (- dd 29))
353           (setq dd (- dd (nth mm mdays))))
354         (setq mm (1+ mm)))
355       (setq HH (/ low 3600)
356             low (% low 3600)
357             MM (/ low 60)
358             SS (% low 60))
359       (format "%s %s %2d %02d:%02d:%02d %4d"
360               (nth (% (+ days
361                          (- (+ (* (1- yyyy) 365) (/ (1- yyyy) 400) 
362                                (/ (1- yyyy) 4)) (/ (1- yyyy) 100))) 7)
363                    wnames)
364               (nth mm mnames)
365               dd HH MM SS yyyy))))
366
367 (defun current-time ()
368   "Return the current time, as the number of seconds since 1970-01-01 00:00:00.
369 The time is returned as a list of three integers.  The first has the
370 most significant 16 bits of the seconds, while the second has the
371 least significant 16 bits.  The third integer gives the microsecond
372 count.
373
374 The microsecond count is zero on systems that do not provide
375 resolution finer than a second."
376   (let* ((str (current-time-string))
377          (yyyy (string-to-int (substring str 20 24)))
378          (mm (length (member (substring str 4 7)
379                              '("Dec" "Nov" "Oct" "Sep" "Aug" "Jul"
380                                "Jun" "May" "Apr" "Mar" "Feb" "Jan"))))
381          (dd (string-to-int (substring str 8 10)))
382          (HH (string-to-int (substring str 11 13)))
383          (MM (string-to-int (substring str 14 16)))
384          (SS (string-to-int (substring str 17 19)))
385          (offset (or (car (current-time-zone)) 0))
386          dn ct1 ct2 i1 i2
387          year uru)
388     (setq ct1 0 ct2 0 i1 0 i2 0)
389     (setq year (- yyyy 1970))
390     (while (> year 0)
391       (setq year (1- year)
392             ct1 (+ ct1 481)
393             ct2 (+ ct2 13184))
394       (while (> ct2 65535)
395         (setq ct1 (1+ ct1)
396               ct2 (- ct2 65536))))
397     (setq uru (- (+ (- (/ yyyy 4) (/ yyyy 100)) 
398                     (/ yyyy 400)) 477))
399     (while (> uru 0)
400       (setq uru (1- uru)
401             i1 (1+ i1)
402             i2 (+ i2 20864))
403       (if (> i2 65535)
404           (setq i1 (1+ i1)
405                 i2 (- i2 65536))))
406     (setq ct1 (+ ct1 i1)
407           ct2 (+ ct2 i2))
408     (while (> ct2 65535)
409       (setq ct1 (1+ ct1)
410             ct2 (- ct2 65536)))
411     (setq dn (+ dd (* 31 (1- mm))))
412     (if (> mm 2)
413         (setq dn (+ (- dn (/ (+ 23 (* 4 mm)) 10))
414                     (if (and (zerop (% yyyy 4))
415                              (or (not (zerop (% yyyy 100)))
416                                  (zerop (% yyyy 400))))
417                         1 0))))
418     (setq dn (1- dn)
419           i1 0 
420           i2 0)
421     (while (> dn 0)
422       (setq dn (1- dn)
423             i1 (1+ i1)
424             i2 (+ i2 20864))
425       (if (> i2 65535)
426           (setq i1 (1+ i1)
427                 i2 (- i2 65536))))
428     (setq ct1 (+ (+ (+ ct1 i1) (/ ct2 65536)) 
429                  (/ (+ (* HH 3600) (* MM 60) SS)
430                     65536))
431           ct2 (+ (+ i2 (% ct2 65536))
432                  (% (+ (* HH 3600) (* MM 60) SS)
433                     65536)))
434     (while (< (- ct2 offset) 0)
435       (setq ct1 (1- ct1)
436             ct2 (+ ct2 65536)))
437     (setq ct2 (- ct2 offset))
438     (while (> ct2 65535)
439       (setq ct1 (1+ ct1)
440             ct2 (- ct2 65536)))
441     (list ct1 ct2 0)))
442
443 ;;; @@ Floating point numbers.
444 ;;;
445
446 (defalias 'numberp 'integerp)
447
448 (defun abs (arg)
449   "Return the absolute value of ARG."
450   (if (< arg 0) (- arg) arg))
451
452
453 ;;; @ Basic lisp subroutines.
454 ;;;
455
456 (defmacro lambda (&rest cdr)
457   "Return a lambda expression.
458 A call of the form (lambda ARGS DOCSTRING INTERACTIVE BODY) is
459 self-quoting; the result of evaluating the lambda expression is the
460 expression itself.  The lambda expression may then be treated as a
461 function, i.e., stored as the function value of a symbol, passed to
462 funcall or mapcar, etc.
463
464 ARGS should take the same form as an argument list for a `defun'.
465 DOCSTRING is an optional documentation string.
466  If present, it should describe how to call the function.
467  But documentation strings are usually not useful in nameless functions.
468 INTERACTIVE should be a call to the function `interactive', which see.
469 It may also be omitted.
470 BODY should be a list of lisp expressions."
471   ;; Note that this definition should not use backquotes; subr.el should not
472   ;; depend on backquote.el.
473   (list 'function (cons 'lambda cdr)))
474
475 (defun force-mode-line-update (&optional all)
476   "Force the mode-line of the current buffer to be redisplayed.
477 With optional non-nil ALL, force redisplay of all mode-lines."
478   (if all (save-excursion (set-buffer (other-buffer))))
479   (set-buffer-modified-p (buffer-modified-p)))
480
481 (defalias 'set-match-data 'store-match-data)
482
483 (defvar save-match-data-internal)
484
485 ;; We use save-match-data-internal as the local variable because
486 ;; that works ok in practice (people should not use that variable elsewhere).
487 (defmacro save-match-data (&rest body)
488   "Execute the BODY forms, restoring the global value of the match data."
489   (` (let ((save-match-data-internal (match-data)))
490        (unwind-protect (progn (,@ body))
491          (set-match-data save-match-data-internal)))))
492
493
494 ;;; @ Basic editing commands.
495 ;;;
496
497 ;; 18.55 does not have this variable.
498 (defvar buffer-undo-list nil)
499
500 (defalias 'buffer-disable-undo 'buffer-flush-undo)
501
502 (defun generate-new-buffer-name (name &optional ignore)
503   "Return a string that is the name of no existing buffer based on NAME.
504 If there is no live buffer named NAME, then return NAME.
505 Otherwise modify name by appending `<NUMBER>', incrementing NUMBER
506 until an unused name is found, and then return that name.
507 Optional second argument IGNORE specifies a name that is okay to use
508 \(if it is in the sequence to be tried\)
509 even if a buffer with that name exists."
510   (if (get-buffer name)
511       (let ((n 2) new)
512         (while (get-buffer (setq new (format "%s<%d>" name n)))
513           (setq n (1+ n)))
514         new)
515     name))
516
517 (or (fboundp 'si:mark)
518     (fset 'si:mark (symbol-function 'mark)))
519 (defun mark (&optional force)
520   (si:mark))
521
522
523 ;;; @@ Environment variables.
524 ;;;
525
526 (autoload 'setenv "env"
527   "Set the value of the environment variable named VARIABLE to VALUE.
528 VARIABLE should be a string.  VALUE is optional; if not provided or is
529 `nil', the environment variable VARIABLE will be removed.
530 This function works by modifying `process-environment'."
531   t)
532
533
534 ;;; @ File input and output commands.
535 ;;;
536
537 (defvar data-directory exec-directory)
538
539 ;; In 18.55, `call-process' does not return exit status.
540 (defun file-executable-p (filename)
541   "Return t if FILENAME can be executed by you.
542 For a directory, this means you can access files in that directory."
543   (if (file-exists-p filename)
544       (let ((process (start-process "test" nil "test" "-x" filename)))
545         (while (eq 'run (process-status process)))
546         (zerop (process-exit-status process)))))
547
548 (defun make-directory-internal (dirname)
549   "Create a directory. One argument, a file name string."
550  (let ((dir (expand-file-name dirname)))
551    (if (file-exists-p dir)
552        (error "Creating directory: %s is already exist" dir)
553      (call-process "mkdir" nil nil nil dir))))
554
555 (defun make-directory (dir &optional parents)
556   "Create the directory DIR and any nonexistent parent dirs.
557 The second (optional) argument PARENTS says whether
558 to create parent directories if they don't exist."
559   (let ((len (length dir))
560         (p 0) p1 path)
561     (catch 'tag
562       (while (and (< p len) (string-match "[^/]*/?" dir p))
563         (setq p1 (match-end 0))
564         (if (= p1 len)
565             (throw 'tag nil))
566         (setq path (substring dir 0 p1))
567         (if (not (file-directory-p path))
568             (cond ((file-exists-p path)
569                    (error "Creating directory: %s is not directory" path))
570                   ((null parents)
571                    (error "Creating directory: %s is not exist" path))
572                   (t
573                    (make-directory-internal path))))
574         (setq p p1)))
575     (make-directory-internal dir)))
576
577 (defun parse-colon-path (cd-path)
578   "Explode a colon-separated list of paths into a string list."
579   (and cd-path
580        (let (cd-prefix cd-list (cd-start 0) cd-colon)
581          (setq cd-path (concat cd-path path-separator))
582          (while (setq cd-colon (string-match path-separator cd-path cd-start))
583            (setq cd-list
584                  (nconc cd-list
585                         (list (if (= cd-start cd-colon)
586                                   nil
587                                 (substitute-in-file-name
588                                  (file-name-as-directory
589                                   (substring cd-path cd-start cd-colon)))))))
590            (setq cd-start (+ cd-colon 1)))
591          cd-list)))
592
593 (defun file-relative-name (filename &optional directory)
594   "Convert FILENAME to be relative to DIRECTORY (default: default-directory)."
595   (setq filename (expand-file-name filename)
596         directory (file-name-as-directory (expand-file-name
597                                            (or directory default-directory))))
598   (let ((ancestor ""))
599     (while (not (string-match (concat "^" (regexp-quote directory)) filename))
600       (setq directory (file-name-directory (substring directory 0 -1))
601             ancestor (concat "../" ancestor)))
602     (concat ancestor (substring filename (match-end 0)))))
603
604 (or (fboundp 'si:directory-files)
605     (fset 'si:directory-files (symbol-function 'directory-files)))
606 (defun directory-files (directory &optional full match nosort)
607   "Return a list of names of files in DIRECTORY.
608 There are three optional arguments:
609 If FULL is non-nil, return absolute file names.  Otherwise return names
610  that are relative to the specified directory.
611 If MATCH is non-nil, mention only file names that match the regexp MATCH.
612 If NOSORT is dummy for compatibility."
613   (si:directory-files directory full match))
614
615
616 ;;; @ Text property.
617 ;;;
618
619 ;; In Emacs 20.4, these functions are defined in src/textprop.c.
620 (defun text-properties-at (position &optional object))
621 (defun get-text-property (position prop &optional object))
622 (defun get-char-property (position prop &optional object))
623 (defun next-property-change (position &optional object limit))
624 (defun next-single-property-change (position prop &optional object limit))
625 (defun previous-property-change (position &optional object limit))
626 (defun previous-single-property-change (position prop &optional object limit))
627 (defun add-text-properties (start end properties &optional object))
628 (defun put-text-property (start end property &optional object))
629 (defun set-text-properties (start end properties &optional object))
630 (defun remove-text-properties (start end properties &optional object))
631 (defun text-property-any (start end property value &optional object))
632 (defun text-property-not-all (start end property value &optional object))
633 ;; the following two functions are new in v20.
634 (defun next-char-property-change (position &optional object))
635 (defun previous-char-property-change (position &optional object))
636 ;; the following two functions are obsolete.
637 ;; (defun erase-text-properties (start end &optional object)
638 ;; (defun copy-text-properties (start end src pos dest &optional prop)
639
640
641 ;;; @ Overlay.
642 ;;;
643
644 (cond
645  ((boundp 'NEMACS)
646   (defvar emu:available-face-attribute-alist
647     '(
648       ;;(bold      . inversed-region)
649       (italic    . underlined-region)
650       (underline . underlined-region)))
651
652   ;; by YAMATE Keiichirou 1994/10/28
653   (defun attribute-add-narrow-attribute (attr from to)
654     (or (consp (symbol-value attr))
655         (set attr (list 1)))
656     (let* ((attr-value (symbol-value attr))
657            (len (car attr-value))
658            (posfrom 1)
659            posto)
660       (while (and (< posfrom len)
661                   (> from (nth posfrom attr-value)))
662         (setq posfrom (1+ posfrom)))
663       (setq posto posfrom)
664       (while (and (< posto len)
665                   (> to (nth posto attr-value)))
666         (setq posto (1+ posto)))
667       (if  (= posto posfrom)
668           (if (= (% posto 2) 1)
669               (if (and (< to len)
670                        (= to (nth posto attr-value)))
671                   (set-marker (nth posto attr-value) from)
672                 (setcdr (nthcdr (1- posfrom) attr-value)
673                         (cons (set-marker-type (set-marker (make-marker)
674                                                            from)
675                                                'point-type)
676                               (cons (set-marker-type
677                                      (set-marker (make-marker)
678                                                  to)
679                                      nil)
680                                     (nthcdr posto attr-value))))
681                 (setcar attr-value (+ len 2))))
682         (if (= (% posfrom 2) 0)
683             (setq posfrom (1- posfrom))
684           (set-marker (nth posfrom attr-value) from))
685         (if (= (% posto 2) 0)
686             nil
687           (setq posto (1- posto))
688           (set-marker (nth posto attr-value) to))
689         (setcdr (nthcdr posfrom attr-value)
690                 (nthcdr posto attr-value)))))
691
692   (defalias 'make-overlay 'cons)
693
694   (defun overlay-put (overlay prop value)
695     (let ((ret (and (eq prop 'face)
696                     (assq value emu:available-face-attribute-alist))))
697       (if ret
698           (attribute-add-narrow-attribute (cdr ret)
699                                           (car overlay)(cdr overlay))))))
700  (t
701   (defun make-overlay (beg end &optional buffer type))
702   (defun overlay-put (overlay prop value))))
703
704 (defun overlay-buffer (overlay))
705
706
707 ;;; @ End.
708 ;;;
709
710 (require 'product)
711 (product-provide (provide 'poe-18) (require 'apel-ver))
712
713 ;;; poe-18.el ends here