all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Leo Liu <sdl.web@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 18341@debbugs.gnu.org
Subject: bug#18341: 24.4.50; [patch] control where hook is added minibuffer-with-setup-hook
Date: Fri, 29 Aug 2014 09:14:16 +0800	[thread overview]
Message-ID: <m31ts03xnb.fsf@gmail.com> (raw)
In-Reply-To: <jwvoav492sf.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Thu, 28 Aug 2014 09:12:26 -0400")

On 2014-08-28 09:12 -0400, Stefan Monnier wrote:
> Maybe a simpler change is to let FUN be of the form (:append FUN).

Make sense ;)

=== modified file 'lisp/files.el'
--- lisp/files.el	2014-08-12 02:35:24 +0000
+++ lisp/files.el	2014-08-29 01:11:08 +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 (: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,7 +1386,11 @@
 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)
+      (pop fun))
     `(let ((,funsym ,fun)
            ,hook)
        (setq ,hook
@@ -1394,7 +1401,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)))))





  reply	other threads:[~2014-08-29  1:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2014-08-29  2:03     ` Stefan Monnier
2014-08-29  2:51       ` Leo Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m31ts03xnb.fsf@gmail.com \
    --to=sdl.web@gmail.com \
    --cc=18341@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.