]> git.eshelyaron.com Git - emacs.git/commitdiff
(remove-hook): Doc string added.
authorRichard M. Stallman <rms@gnu.org>
Mon, 2 Aug 1993 07:23:24 +0000 (07:23 +0000)
committerRichard M. Stallman <rms@gnu.org>
Mon, 2 Aug 1993 07:23:24 +0000 (07:23 +0000)
Change a single function into a list.

lisp/emacs-lisp/lucid.el

index 144aaf35b222f92874a0572a6dc5a4b23b67fcc6..eaa405afd336484a35177e9b9fe4224cd89b91f9 100644 (file)
        (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)))