From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Luc Teirlinck <teirllm@dms.auburn.edu>, emacs-devel@gnu.org
Subject: Re: bug in file-name-shadow-mode
Date: Mon, 21 Mar 2005 11:20:43 -0500 [thread overview]
Message-ID: <jwveke9q8cn.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1DDBZb-000554-9v@fencepost.gnu.org> (Richard Stallman's message of "Sun, 20 Mar 2005 20:19:15 -0500")
> Do C-g to quit the current minibuffer. Then do C-x C-f.
> One now has ~/ in the minibuffer. If you type an extra "/", the "~/"
> preceding it does not get any special highlighting, as it should if
> file-name-shadow-mode is t.
> The cause of this is that the minibuffer binds minibuffer-setup-hook
> and therefore the local binding is what gets set. Thus, exiting the
> minibuffer wipes it out.
> I think there is nothing to be done about this. It would be hard to
> fix and it probably isn't worth the trouble.
How 'bout the untested patch below?
Stefan
--- files.el 15 fév 2005 11:00:48 -0500 1.745
+++ files.el 21 mar 2005 11:19:48 -0500
@@ -928,20 +928,30 @@
(defvar find-file-default nil
"Used within `find-file-read-args'.")
+(defmacro minibuffer-with-setup-hook (fun &rest body)
+ "Add FUN to `minibuffer-setup-hook' while executing BODY.
+BODY should use the minibuffer at most once.
+Recursive uses of the minibuffer will not be affected."
+ (declare (indent 1) (debug t))
+ (let ((funname (make-symbol "setup-hook"))
+ (oldval (make-symbol "old-val")))
+ `(unwind-protect
+ (progn
+ (fset ',funname (lambda () (,fun)
+ ;; Clear out this hook so it does not interfere
+ ;; with any recursive minibuffer usage.
+ (remove-hook 'minibuffer-setup-hook ',funname)))
+ (add-hook 'minibuffer-setup-hook ',funname)
+ ,@body)
+ (remove-hook 'minibuffer-setup-hook ',funname))))
+
(defun find-file-read-args (prompt mustmatch)
(list (let ((find-file-default
(and buffer-file-name
- (abbreviate-file-name buffer-file-name)))
- (munge-default-fun
- (lambda ()
- (setq minibuffer-default find-file-default)
- ;; Clear out this hook so it does not interfere
- ;; with any recursive minibuffer usage.
- (pop minibuffer-setup-hook)))
- (minibuffer-setup-hook
- minibuffer-setup-hook))
- (add-hook 'minibuffer-setup-hook munge-default-fun)
- (read-file-name prompt nil default-directory mustmatch))
+ (abbreviate-file-name buffer-file-name))))
+ (minibuffer-with-setup-hook
+ (lambda () (setq minibuffer-default find-file-default))
+ (read-file-name prompt nil default-directory mustmatch)))
t))
(defun find-file (filename &optional wildcards)
next prev parent reply other threads:[~2005-03-21 16:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-19 20:12 bug in file-name-shadow-mode Luc Teirlinck
2005-03-20 12:59 ` Richard Stallman
2005-03-20 16:26 ` Luc Teirlinck
2005-03-21 1:19 ` Richard Stallman
2005-03-21 16:20 ` Stefan Monnier [this message]
2005-03-22 0:04 ` Luc Teirlinck
2005-03-22 3:34 ` Richard Stallman
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwveke9q8cn.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=teirllm@dms.auburn.edu \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).