]> git.eshelyaron.com Git - emacs.git/commitdiff
* files.el (minibuffer-with-setup-hook): Allow (:append FUN) to
authorLeo Liu <sdl.web@gmail.com>
Fri, 29 Aug 2014 02:48:17 +0000 (10:48 +0800)
committerLeo Liu <sdl.web@gmail.com>
Fri, 29 Aug 2014 02:48:17 +0000 (10:48 +0800)
append to minibuffer-setup-hook.

Fixes: debbugs:18341
lisp/ChangeLog
lisp/files.el

index e41633548c64a0a1ece8cda3855b71d72c4b78c7..531196aeda616a4617db169dcba306f2499a2a85 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-29  Leo Liu  <sdl.web@gmail.com>
+
+       * files.el (minibuffer-with-setup-hook): Allow (:append FUN) to
+       append to minibuffer-setup-hook.  (Bug#18341)
+
 2014-08-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * progmodes/cc-defs.el: Expose c-lanf-defconst's expressions to the
index edbf647530cee329024b709033c85d0b5447b3e7..486dee638a9650ef6001b0fb0db86a3e4c5b3a11 100644 (file)
@@ -1375,6 +1375,9 @@ return value, which may be passed as the REQUIRE-MATCH arg to
 
 (defmacro minibuffer-with-setup-hook (fun &rest body)
   "Temporarily add FUN to `minibuffer-setup-hook' while executing BODY.
+FUN can also be (: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,20 +1386,23 @@ This macro actually adds an auxiliary function that calls FUN,
 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) fun (cadr fun)))
     `(let ((,funsym ,fun)
            ,hook)
        (setq ,hook
-            (lambda ()
-              ;; Clear out this hook so it does not interfere
-              ;; with any recursive minibuffer usage.
-              (remove-hook 'minibuffer-setup-hook ,hook)
-              (funcall ,funsym)))
+             (lambda ()
+               ;; Clear out this hook so it does not interfere
+               ;; with any recursive minibuffer usage.
+               (remove-hook 'minibuffer-setup-hook ,hook)
+               (funcall ,funsym)))
        (unwind-protect
-          (progn
-            (add-hook 'minibuffer-setup-hook ,hook)
-            ,@body)
-        (remove-hook 'minibuffer-setup-hook ,hook)))))
+           (progn
+             (add-hook 'minibuffer-setup-hook ,hook ,@append)
+             ,@body)
+         (remove-hook 'minibuffer-setup-hook ,hook)))))
 
 (defun find-file-read-args (prompt mustmatch)
   (list (read-file-name prompt nil default-directory mustmatch)