From 12e786db9a3aea423ac9ab0c33f52735f3b0e9fd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 15 Mar 2017 22:40:04 -0400 Subject: [PATCH] Fix remove-hook! macro --- core/core-lib.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index 877cb66f2..d28973085 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -138,7 +138,8 @@ Examples: Body forms can access the hook's arguments through the let-bound variable `args'." (declare (indent defun) (debug t)) - (let (hook append-p local-p) + (let ((hook-fn (if (boundp 'hook-fn) hook-fn)) + hook append-p local-p) (while (keywordp (car args)) (pcase (pop args) (:append (setq append-p t)) @@ -157,8 +158,10 @@ Body forms can access the hook's arguments through the let-bound variable `(quote ,fn) `(lambda (&rest args) ,@args))) (dolist (hook hooks) - (push `(,(if (boundp 'hook-fn) hook-fn 'add-hook) - ',hook ,fn ,append-p ,local-p) + (push (cond ((eq hook-fn 'remove-hook) + `(remove-hook ',hook ,fn ,local-p)) + (t + `(add-hook ',hook ,fn ,append-p ,local-p))) forms))) `(progn ,@(nreverse forms)))))