aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond1993-03-27 01:58:44 +0000
committerEric S. Raymond1993-03-27 01:58:44 +0000
commit08159178ca75f2b6fb226988e1905849d7906f3a (patch)
tree60b304a2070b827816c86d463475695c48aa6711
parent1c2df06340453138e48857c93e6eee1842833c14 (diff)
downloademacs-08159178ca75f2b6fb226988e1905849d7906f3a.tar.gz
emacs-08159178ca75f2b6fb226988e1905849d7906f3a.zip
(add-hook) Added optional arg to cause hook to be appended rather than
prepended to the hook list. This obviates the 23 different hook-bashing packages in LCD. (get-word) Added. Lots of help and default-generator functions in LCD use it, and it's remarkably difficult to get right, especially given the new syntax primitives.
-rw-r--r--lisp/subr.el16
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 464fea25f9c..e6ec3b3b613 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -407,11 +407,12 @@ If it is a list, the elements are called, in order, with no arguments."
407 "Variable by which C primitives find the function `run-hooks'. 407 "Variable by which C primitives find the function `run-hooks'.
408Don't change it.") 408Don't change it.")
409 409
410(defun add-hook (hook function) 410(defun add-hook (hook function &optional append)
411 "Add to the value of HOOK the function FUNCTION unless already present. 411 "Add to the value of HOOK the function FUNCTION unless already present (it
412HOOK should be a symbol, and FUNCTION may be any valid function. 412becomes the first hook on the list unless optional APPEND is non-nil, in
413HOOK's value should be a list of functions, not a single function. 413which case it becomes the last). HOOK should be a symbol, and FUNCTION may be
414If HOOK is void, it is first set to nil." 414any valid function. HOOK's value should be a list of functions, not a single
415function. If HOOK is void, it is first set to nil."
415 (or (boundp hook) (set hook nil)) 416 (or (boundp hook) (set hook nil))
416 (or (if (consp function) 417 (or (if (consp function)
417 ;; Clever way to tell whether a given lambda-expression 418 ;; Clever way to tell whether a given lambda-expression
@@ -419,7 +420,10 @@ If HOOK is void, it is first set to nil."
419 (let ((tail (assoc (cdr function) (symbol-value hook)))) 420 (let ((tail (assoc (cdr function) (symbol-value hook))))
420 (equal function tail)) 421 (equal function tail))
421 (memq function (symbol-value hook))) 422 (memq function (symbol-value hook)))
422 (set hook (cons function (symbol-value hook))))) 423 (set hook
424 (if append
425 (nconc (symbol-value hook) (list function))
426 (cons function (symbol-value hook))))))
423 427
424(defun momentary-string-display (string pos &optional exit-char message) 428(defun momentary-string-display (string pos &optional exit-char message)
425 "Momentarily display STRING in the buffer at POS. 429 "Momentarily display STRING in the buffer at POS.