emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: abbreviate-file-name on Windows seems incorrect


From: Lennart Borgman (gmail)
Subject: Re: abbreviate-file-name on Windows seems incorrect
Date: Sat, 06 Jan 2007 12:37:25 +0100
User-agent: Thunderbird 1.5.0.9 (Windows/20061207)

Drew Adams wrote:
On MS Windows, my $HOME is "c:\\". That is what is returned by (getenv
"HOME"), and that is what I see in Windows itself, in the list of
environment vars.

The code for `abbreviate-file-name' defines `abbreviated-home-dir' as
follows, in order to be able to "substitute `~' for the user's home
directory", as the doc string says:

(or abbreviated-home-dir
    (setq abbreviated-home-dir
          (let ((abbreviated-home-dir "$foo"))
            (concat "^" (abbreviate-file-name
                         (expand-file-name "~"))
                    "\\(/\\|\\'\\)"))))

The comment for this code is as follows, which indicates that a slash is
added to distinguish the home dir from a file in that dir:

    ;; We include a slash at the end, to avoid spurious matches
    ;; such as `/usr/foobar' when the home dir is `/usr/foo'.

However, that is improper for a Windows home directory such as mine (not an
uncommon value).  (expand-file-name "~") returns "c:/", which is correct,
but the result for `abbreviated-home-dir' becomes "^c:/\\(/\\|\\'\\)", which
is incorrect and useless, AFAICT. It should be something like
"^c:\\(/\\|\\'\\)", I would think.

I would expect (abbreviate-file-name "c:/foo/bar") to return "~/foo/bar",
but it returns "c:/foo/bar". If `abbreviated-home-dir' were
"^c:\\(/\\|\\'\\)", then the result would be correct: "~/foo/bar".



If leave abbreviated-home-dir as "^c:/\\(/\\|\\'\\)" and you instead just comment out this part in abbreviate-file-name, does it works as you expect then? :

               ;; MS-DOS root directories can come with a drive letter;
               ;; Novell Netware allows drive letters beyond `Z:'.
               (not (and (or (eq system-type 'ms-dos)
                             (eq system-type 'cygwin)
                             (eq system-type 'windows-nt))
                         (save-match-data
                           (string-match "^[a-zA-`]:/$" filename)))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]