From: Richard M. Stallman Date: Mon, 2 Aug 1993 07:23:24 +0000 (+0000) Subject: (remove-hook): Doc string added. X-Git-Tag: emacs-19.34~11436 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=23f87cce43f42f8e623da0fe8abeabd0af76022a;p=emacs.git (remove-hook): Doc string added. Change a single function into a list. --- diff --git a/lisp/emacs-lisp/lucid.el b/lisp/emacs-lisp/lucid.el index 144aaf35b22..eaa405afd33 100644 --- a/lisp/emacs-lisp/lucid.el +++ b/lisp/emacs-lisp/lucid.el @@ -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)))