emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r117763: * files.el (minibuffer-with-setup-hook): Al


From: Leo Liu
Subject: [Emacs-diffs] trunk r117763: * files.el (minibuffer-with-setup-hook): Allow (:append FUN) to
Date: Fri, 29 Aug 2014 02:50:10 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117763
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/18341
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Fri 2014-08-29 10:48:17 +0800
message:
  * files.el (minibuffer-with-setup-hook): Allow (:append FUN) to
  append to minibuffer-setup-hook.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/files.el                  files.el-20091113204419-o5vbwnq5f7feedwu-265
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-08-28 20:37:13 +0000
+++ b/lisp/ChangeLog    2014-08-29 02:48:17 +0000
@@ -1,3 +1,8 @@
+2014-08-29  Leo Liu  <address@hidden>
+
+       * files.el (minibuffer-with-setup-hook): Allow (:append FUN) to
+       append to minibuffer-setup-hook.  (Bug#18341)
+
 2014-08-28  Stefan Monnier  <address@hidden>
 
        * progmodes/cc-defs.el: Expose c-lanf-defconst's expressions to the

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2014-08-12 02:35:24 +0000
+++ b/lisp/files.el     2014-08-29 02:48:17 +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 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 @@
 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)


reply via email to

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