[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in file-name-shadow-mode
From: |
Stefan Monnier |
Subject: |
Re: bug in file-name-shadow-mode |
Date: |
Mon, 21 Mar 2005 11:20:43 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
> 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)