--- Begin Message ---
Subject: |
24.4.50; [patch] control where hook is added minibuffer-with-setup-hook |
Date: |
Thu, 28 Aug 2014 12:54:45 +0800 |
Any objection to extending minibuffer-with-setup-hook so that one can
control where the hook is added.
I have often wanted the `append' option because other hook functions can
cancel my work. Will fix the doc-string once the patch is accepted.
Thanks,
Leo
=== modified file 'lisp/files.el'
--- lisp/files.el 2014-08-12 02:35:24 +0000
+++ lisp/files.el 2014-08-28 04:46:15 +0000
@@ -1373,7 +1373,7 @@
'confirm)
(t nil)))
-(defmacro minibuffer-with-setup-hook (fun &rest body)
+(defmacro minibuffer-with-setup-hook (fun append &rest body)
"Temporarily add FUN to `minibuffer-setup-hook' while executing BODY.
BODY should use the minibuffer at most once.
Recursive uses of the minibuffer are unaffected (FUN is not
@@ -1381,9 +1381,11 @@
This macro actually adds an auxiliary function that calls FUN,
rather than FUN itself, to `minibuffer-setup-hook'."
- (declare (indent 1) (debug t))
+ (declare (indent 2) (debug t))
(let ((hook (make-symbol "setup-hook"))
- (funsym (make-symbol "fun")))
+ (funsym (make-symbol "fun"))
+ (body (if (booleanp append) body (push append body)))
+ (append (and (booleanp append) append)))
`(let ((,funsym ,fun)
,hook)
(setq ,hook
@@ -1394,7 +1396,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)))))
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#18341: 24.4.50; [patch] control where hook is added minibuffer-with-setup-hook |
Date: |
Fri, 29 Aug 2014 10:51:48 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (CentOS 6.5) |
version: 24.5
On 2014-08-28 22:03 -0400, Stefan Monnier wrote:
> Please make it '(t) so you can use ,@append and get marginally cleaner
> macroexpanded code when :append is not used.
>
>> + (pop fun))
>
> I think this implements (:append . FUN) rather than (:append FUN).
> Other than that, feel free to install into trunk.
Thanks for these comments and sorry for my mistakes.
Leo
--- End Message ---