aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-08-02 07:23:07 +0000
committerRichard M. Stallman1993-08-02 07:23:07 +0000
commit322959764a2b05f0210adc474fab6876b45cb53f (patch)
tree0f55311ca3778f9232426cbf7a6fa6199ee305be
parent47f3858d11f27453e6eeca07388a910c51df4dfd (diff)
downloademacs-322959764a2b05f0210adc474fab6876b45cb53f.tar.gz
emacs-322959764a2b05f0210adc474fab6876b45cb53f.zip
(add-hook): Change a single function into a list.
-rw-r--r--lisp/subr.el26
1 files changed, 20 insertions, 6 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 031c7ff4421..c1717f553d3 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -296,7 +296,8 @@ The normal global definition of the character C-x indirects to this keymap.")
296(defun event-modifiers (event) 296(defun event-modifiers (event)
297 "Returns a list of symbols representing the modifier keys in event EVENT. 297 "Returns a list of symbols representing the modifier keys in event EVENT.
298The elements of the list may include `meta', `control', 298The elements of the list may include `meta', `control',
299`shift', `hyper', `super', `alt', `click', `drag', and `down'." 299`shift', `hyper', `super', `alt', `click', `double', `triple', `drag',
300and `down'."
300 (let ((type event)) 301 (let ((type event))
301 (if (listp type) 302 (if (listp type)
302 (setq type (car type))) 303 (setq type (car type)))
@@ -352,6 +353,11 @@ The return value is of the form
352The `posn-' functions access elements of such lists." 353The `posn-' functions access elements of such lists."
353 (nth (if (consp (nth 2 event)) 2 1) event)) 354 (nth (if (consp (nth 2 event)) 2 1) event))
354 355
356(defsubst event-click-count (event)
357 "Return the multi-click count of EVENT, a click or drag event.
358The return value is a positive integer."
359 (if (integerp (nth 2 event)) (nth 2 event) 1))
360
355(defsubst posn-window (position) 361(defsubst posn-window (position)
356 "Return the window in POSITION. 362 "Return the window in POSITION.
357POSITION should be a list of the form 363POSITION should be a list of the form
@@ -460,12 +466,20 @@ If it is a list, the elements are called, in order, with no arguments."
460Don't change it.") 466Don't change it.")
461 467
462(defun add-hook (hook function &optional append) 468(defun add-hook (hook function &optional append)
463 "Add to the value of HOOK the function FUNCTION unless already present (it 469 "Add to the value of HOOK the function FUNCTION.
464becomes the first hook on the list unless optional APPEND is non-nil, in 470FUNCTION is not added if already present.
465which case it becomes the last). HOOK should be a symbol, and FUNCTION may be 471FUNCTION is added (if necessary) at the beginning of the hook list
466any valid function. HOOK's value should be a list of functions, not a single 472unless the optional argument APPEND is non-nil, in which case
467function. If HOOK is void, it is first set to nil." 473FUNCTION is added at the end.
474
475HOOK should be a symbol, and FUNCTION may be any valid function. If
476HOOK is void, it is first set to nil. If HOOK's value is a single
477function, it is changed to a list of functions."
468 (or (boundp hook) (set hook nil)) 478 (or (boundp hook) (set hook nil))
479 ;; If the hook value is a single function, turn it into a list.
480 (let ((old (symbol-value hook)))
481 (if (or (not (listp old)) (eq (car old) 'lambda))
482 (set hook (list old))))
469 (or (if (consp function) 483 (or (if (consp function)
470 ;; Clever way to tell whether a given lambda-expression 484 ;; Clever way to tell whether a given lambda-expression
471 ;; is equal to anything in the hook. 485 ;; is equal to anything in the hook.