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.

Full log


View this message in rfc822 format

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




This bug report was last modified 10 years and 232 days ago.

Previous Next


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