all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#18341: 24.4.50; [patch] control where hook is added minibuffer-with-setup-hook
@ 2014-08-28  4:54 Leo Liu
  2014-08-28 13:12 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Liu @ 2014-08-28  4:54 UTC (permalink / raw)
  To: 18341


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)))))





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-29  2:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-28  4:54 bug#18341: 24.4.50; [patch] control where hook is added minibuffer-with-setup-hook Leo Liu
2014-08-28 13:12 ` Stefan Monnier
2014-08-29  1:14   ` Leo Liu
2014-08-29  2:03     ` Stefan Monnier
2014-08-29  2:51       ` Leo Liu

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.