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