GNU bug report logs - #18341
24.4.50; [patch] control where hook is added minibuffer-with-setup-hook

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Thu, 28 Aug 2014 04:56:01 UTC

Severity: wishlist

Tags: patch

Found in version 24.4.50

Fixed in version 25.1

Done: Leo Liu <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18341 in the body.
You can then email your comments to 18341 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18341; Package emacs. (Thu, 28 Aug 2014 04:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Liu <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 28 Aug 2014 04:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
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)))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18341; Package emacs. (Thu, 28 Aug 2014 13:13:02 GMT) Full text and rfc822 format available.

Message #8 received at 18341 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 18341 <at> debbugs.gnu.org
Subject: Re: bug#18341: 24.4.50;
 [patch] control where hook is added minibuffer-with-setup-hook
Date: Thu, 28 Aug 2014 09:12:26 -0400
> +(defmacro minibuffer-with-setup-hook (fun append &rest body)

Maybe a simpler change is to let FUN be of the form (:append FUN).


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18341; Package emacs. (Fri, 29 Aug 2014 01:15:03 GMT) Full text and rfc822 format available.

Message #11 received at 18341 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 18341 <at> debbugs.gnu.org
Subject: Re: bug#18341: 24.4.50;
 [patch] control where hook is added minibuffer-with-setup-hook
Date: Fri, 29 Aug 2014 09:14:16 +0800
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)))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18341; Package emacs. (Fri, 29 Aug 2014 02:04:02 GMT) Full text and rfc822 format available.

Message #14 received at 18341 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 18341 <at> debbugs.gnu.org
Subject: Re: bug#18341: 24.4.50;
 [patch] control where hook is added minibuffer-with-setup-hook
Date: Thu, 28 Aug 2014 22:03:47 -0400
> +    (when (eq (car-safe fun) :append)
> +      (setq append t)

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.


        Stefan




Reply sent to Leo Liu <sdl.web <at> gmail.com>:
You have taken responsibility. (Fri, 29 Aug 2014 02:53:02 GMT) Full text and rfc822 format available.

Notification sent to Leo Liu <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Fri, 29 Aug 2014 02:53:03 GMT) Full text and rfc822 format available.

Message #19 received at 18341-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 18341-done <at> debbugs.gnu.org
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
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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 26 Sep 2014 11:24:04 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:05 GMT) Full text and rfc822 format available.

bug Marked as fixed in versions 25.1. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:05 GMT) Full text and rfc822 format available.

bug No longer marked as fixed in versions 24.5. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:05 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 Nov 2014 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 189 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.