From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: file-name-shadow-mode Date: Mon, 21 Mar 2005 08:24:38 -0500 Message-ID: <87is3lw2yk.fsf-monnier+emacs@gnu.org> References: <200503180435.j2I4Z2R18621@raven.dms.auburn.edu> <87is3p5zp2.fsf-monnier+emacs@gnu.org> <200503191521.j2JFL8901509@raven.dms.auburn.edu> <87r7ibziw6.fsf-monnier+emacs@gnu.org> <200503200230.j2K2UvS03067@raven.dms.auburn.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1111411850 14161 80.91.229.2 (21 Mar 2005 13:30:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 21 Mar 2005 13:30:50 +0000 (UTC) Cc: emacs-devel@gnu.org, snogglethorpe@gmail.com, teirllm@dms.auburn.edu, miles@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 21 14:30:49 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DDMyI-0005rw-Hr for ged-emacs-devel@m.gmane.org; Mon, 21 Mar 2005 14:29:40 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DDNFO-0007MM-Oe for ged-emacs-devel@m.gmane.org; Mon, 21 Mar 2005 08:47:10 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DDNE0-0006vw-KN for emacs-devel@gnu.org; Mon, 21 Mar 2005 08:45:44 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DDNDs-0006s6-GR for emacs-devel@gnu.org; Mon, 21 Mar 2005 08:45:38 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DDNDs-0006qz-9P for emacs-devel@gnu.org; Mon, 21 Mar 2005 08:45:36 -0500 Original-Received: from [209.226.175.4] (helo=tomts16-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DDMtc-0001uO-Ti; Mon, 21 Mar 2005 08:24:41 -0500 Original-Received: from alfajor ([67.71.26.238]) by tomts16-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050321132439.BOUQ1836.tomts16-srv.bellnexxia.net@alfajor>; Mon, 21 Mar 2005 08:24:39 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id E67CDD72F3; Mon, 21 Mar 2005 08:24:38 -0500 (EST) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Sun, 20 Mar 2005 13:01:27 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: news.gmane.org gmane.emacs.devel:34885 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34885 > 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 ;; 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