tm 6.73.
[elisp/apel.git] / emu-18.el
1 ;;;
2 ;;; emu-18: Emacs 19.* emulation module for Emacs 18.*
3 ;;;
4 ;;; $Id: emu-18.el,v 3.0 1995/08/26 18:07:06 morioka Exp $
5 ;;;
6
7 ;; This function is imported from AUC TeX.
8 (defun add-hook (hook function &optional append)
9   "Add to the value of HOOK the function FUNCTION.
10 FUNCTION is not added if already present.
11 FUNCTION is added (if necessary) at the beginning of the hook list
12 unless the optional argument APPEND is non-nil, in which case
13 FUNCTION is added at the end.
14  
15 HOOK should be a symbol, and FUNCTION may be any valid function.  If
16 HOOK is void, it is first set to nil.  If HOOK's value is a single
17 function, it is changed to a list of functions.
18 \[emu-18 Emacs 19 emulating function]"
19   (or (boundp hook)
20       (set hook nil)
21       )
22   ;; If the hook value is a single function, turn it into a list.
23   (let ((old (symbol-value hook)))
24     (if (or (not (listp old))
25             (eq (car old) 'lambda))
26         (set hook (list old))
27       ))
28   (or (if (consp function)
29           ;; Clever way to tell whether a given lambda-expression
30           ;; is equal to anything in the hook.
31           (let ((tail (assoc (cdr function) (symbol-value hook))))
32             (equal function tail)
33             )
34         (memq function (symbol-value hook))
35         )
36       (set hook 
37            (if append
38                (nconc (symbol-value hook) (list function))
39              (cons function (symbol-value hook))
40              ))
41       ))
42
43 (defun member (elt list)
44   "Return non-nil if ELT is an element of LIST.  Comparison done with EQUAL.
45 The value is actually the tail of LIST whose car is ELT.
46 \[emu-18 Emacs 19 emulating function]"
47   (while (and list (not (equal elt (car list))))
48     (setq list (cdr list)))
49   list)
50
51 (defun defalias (SYM NEWDEF)
52   "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.
53 Associates the function with the current load file, if any.
54 \[emu-18 Emacs 19 emulating function]"
55   (fset SYM (symbol-function NEWDEF))
56   NEWDEF)
57
58 (provide 'emu-18)