> The functionality of rfn-eshadow is quite useful to the vast majority > of users, and indeed is much-requested, and you want to not enable it > because you found a minor flaw? A flaw whose only effect is to make > the prompt slightly less clear that it could be?
I agree that the approximate handling of envvars never seriously bothered me, but it's clearly a bug we should fix. I've OTOH been annoyed by the bad interaction with url-handler-mode, where the file name is most naturally something of the form "http://foo/bar" and rfn-eshadow.el systematically hides the "http:/". > I agree: this bug is not enough reason not to enable the feature. > However, it would be nice to fix the bug. > [I think it's probably possible to fix this -- e.g., by generating a > regexp of all non-absolute environment variables and glomming it onto > the rexexp used for filenames. But my basic point is that it scarcely > matters.] > Could you try fixing it that way? How 'bout the patch below which makes no assumption (that I know of) about substitute-in-file-name, and will thus correctly even with weird magic file name handlers. Stefan --- rfn-eshadow.el 01 sep 2003 11:45:14 -0400 1.12 +++ rfn-eshadow.el 21 mar 2005 08:19:24 -0500 @@ -1,6 +1,6 @@ ;;; rfn-eshadow.el --- Highlight `shadowed' part of read-file-name input text ;; -;; Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +;; Copyright (C) 2000, 2001, 2002, 2005 Free Software Foundation, Inc. ;; ;; Author: Miles Bader <[EMAIL PROTECTED]> ;; Keywords: convenience minibuffer @@ -176,25 +176,25 @@ This is intended to be used as a minibuffer post-command-hook for `file-name-shadow-mode'; the minibuffer should have already been set up by `rfn-eshadow-setup-minibuffer'." - ;; This is not really a correct implementation; it won't always do the - ;; right thing in the presence of environment variables that - ;; substitute-in-file-name would expand; currently it just assumes any - ;; environment variable contains an absolute filename. - (save-excursion - (let ((inhibit-point-motion-hooks t)) - (goto-char (minibuffer-prompt-end)) - ;; Update the overlay (which will evaporate if it's empty). - (move-overlay rfn-eshadow-overlay - (point) - (if (looking-at rfn-eshadow-regexp) - (match-end 1) - (point)))))) - - -;;; Note this definition must be at the end of the file, because -;;; `define-minor-mode' actually calls the mode-function if the -;;; associated variable is non-nil, which requires that all needed -;;; functions be already defined. [This is arguably a bug in d-m-m] + (condition-case nil + (let ((goal (substitute-in-file-name (minibuffer-contents))) + (start (minibuffer-prompt-end)) + (end (point-max))) + ;; Binary search for the greatest position still equivalent to + ;; the whole. + (while (< (1+ start) end) + (let ((mid (/ (+ start end) 2))) + (if (equal (condition-case nil + (substitute-in-file-name + (buffer-substring mid (point-max))) + (error nil)) + goal) + (setq start mid) + (setq end mid)))) + (move-overlay rfn-eshadow-overlay (minibuffer-prompt-end) start)) + ;; `substitute-in-file-name' can fail on partial input. + (error nil))) + ;;;###autoload (define-minor-mode file-name-shadow-mode "Toggle File-Name Shadow mode. @@ -222,5 +222,5 @@ (provide 'rfn-eshadow) -;;; arch-tag: dcf70a52-0115-4ec2-b1e3-4f8d3541a888 +;; arch-tag: dcf70a52-0115-4ec2-b1e3-4f8d3541a888 ;;; rfn-eshadow.el ends here _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel