bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18341: 24.4.50; [patch] control where hook is added minibuffer-with-


From: Leo Liu
Subject: bug#18341: 24.4.50; [patch] control where hook is added minibuffer-with-setup-hook
Date: Fri, 29 Aug 2014 09:14:16 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (CentOS 6.5)

On 2014-08-28 09:12 -0400, Stefan Monnier wrote:
> Maybe a simpler change is to let FUN be of the form (:append FUN).

Make sense ;)

=== modified file 'lisp/files.el'
--- lisp/files.el       2014-08-12 02:35:24 +0000
+++ lisp/files.el       2014-08-29 01:11:08 +0000
@@ -1375,6 +1375,9 @@
 
 (defmacro minibuffer-with-setup-hook (fun &rest body)
   "Temporarily add FUN to `minibuffer-setup-hook' while executing BODY.
+FUN can also (:append FUN1), in which case FUN1 is appended to
+`minibuffer-setup-hook'.
+
 BODY should use the minibuffer at most once.
 Recursive uses of the minibuffer are unaffected (FUN is not
 called additional times).
@@ -1383,7 +1386,11 @@
 rather than FUN itself, to `minibuffer-setup-hook'."
   (declare (indent 1) (debug t))
   (let ((hook (make-symbol "setup-hook"))
-        (funsym (make-symbol "fun")))
+        (funsym (make-symbol "fun"))
+       (append nil))
+    (when (eq (car-safe fun) :append)
+      (setq append t)
+      (pop fun))
     `(let ((,funsym ,fun)
            ,hook)
        (setq ,hook
@@ -1394,7 +1401,7 @@
               (funcall ,funsym)))
        (unwind-protect
           (progn
-            (add-hook 'minibuffer-setup-hook ,hook)
+            (add-hook 'minibuffer-setup-hook ,hook ,append)
             ,@body)
         (remove-hook 'minibuffer-setup-hook ,hook)))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]