Commit fd53ccaa authored by Leo Liu's avatar Leo Liu

* files.el (minibuffer-with-setup-hook): Allow (:append FUN) to

append to minibuffer-setup-hook.

Fixes: debbugs:18341
parent 562d55be
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> 2014-08-28 Stefan Monnier <monnier@iro.umontreal.ca>
* progmodes/cc-defs.el: Expose c-lanf-defconst's expressions to the * progmodes/cc-defs.el: Expose c-lanf-defconst's expressions to the
......
...@@ -1375,6 +1375,9 @@ return value, which may be passed as the REQUIRE-MATCH arg to ...@@ -1375,6 +1375,9 @@ return value, which may be passed as the REQUIRE-MATCH arg to
(defmacro minibuffer-with-setup-hook (fun &rest body) (defmacro minibuffer-with-setup-hook (fun &rest body)
"Temporarily add FUN to `minibuffer-setup-hook' while executing 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. BODY should use the minibuffer at most once.
Recursive uses of the minibuffer are unaffected (FUN is not Recursive uses of the minibuffer are unaffected (FUN is not
called additional times). called additional times).
...@@ -1383,20 +1386,23 @@ This macro actually adds an auxiliary function that calls FUN, ...@@ -1383,20 +1386,23 @@ This macro actually adds an auxiliary function that calls FUN,
rather than FUN itself, to `minibuffer-setup-hook'." rather than FUN itself, to `minibuffer-setup-hook'."
(declare (indent 1) (debug t)) (declare (indent 1) (debug t))
(let ((hook (make-symbol "setup-hook")) (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) `(let ((,funsym ,fun)
,hook) ,hook)
(setq ,hook (setq ,hook
(lambda () (lambda ()
;; Clear out this hook so it does not interfere ;; Clear out this hook so it does not interfere
;; with any recursive minibuffer usage. ;; with any recursive minibuffer usage.
(remove-hook 'minibuffer-setup-hook ,hook) (remove-hook 'minibuffer-setup-hook ,hook)
(funcall ,funsym))) (funcall ,funsym)))
(unwind-protect (unwind-protect
(progn (progn
(add-hook 'minibuffer-setup-hook ,hook) (add-hook 'minibuffer-setup-hook ,hook ,@append)
,@body) ,@body)
(remove-hook 'minibuffer-setup-hook ,hook))))) (remove-hook 'minibuffer-setup-hook ,hook)))))
(defun find-file-read-args (prompt mustmatch) (defun find-file-read-args (prompt mustmatch)
(list (read-file-name prompt nil default-directory mustmatch) (list (read-file-name prompt nil default-directory mustmatch)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment