changeset 4415:b9ce445fb406

(remove-hook): Doc string added. Change a single function into a list.
author Richard M. Stallman <rms@gnu.org>
date Mon, 02 Aug 1993 07:23:24 +0000
parents 3356419b94c1
children 9657ef911049
files lisp/emacs-lisp/lucid.el
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/lucid.el	Mon Aug 02 07:23:07 1993 +0000
+++ b/lisp/emacs-lisp/lucid.el	Mon Aug 02 07:23:24 1993 +0000
@@ -53,8 +53,16 @@
 	(setcdr tail new-parent))))
 
 (defun remove-hook (hook-var function)
+  "Remove a function from a hook, if it is present.
+First argument HOOK-VAR (a symbol) is the name of a hook, second
+ argument FUNCTION is the function to remove (compared with `eq')."
   (if (boundp 'hook-var)
-      (set hook-var (delq function (symbol-value hook-var)))))
+      (let ((old (symbol-value hook-var)))
+	;; If the hook value is a single function, turn it into a list.
+	(if (or (not (listp old)) (eq (car old) 'lambda))
+	    (set hook-var (list old)))
+	;; Now delete FUNCTION.
+	(set hook-var (delq function (symbol-value hook-var))))))
 
 (defun remprop (symbol prop)
   (let ((plist (symbol-plist symbol)))