emacs-devel
[Top][All Lists]

## RE: abbreviate-file-name on Windows seems incorrect

 From: Drew Adams Subject: RE: abbreviate-file-name on Windows seems incorrect Date: Sat, 6 Jan 2007 08:22:09 -0800

```> > I would expect (abbreviate-file-name "c:/foo/bar") to return
> > "~/foo/bar", but it returns "c:/foo/bar".
>
> This is a feature: the Windows port behaves here like the Unix version
> does, and doesn't change the file name if the home directory is a root
> directory.

OK.

> my \$HOME's value is "d:/usr/eli":
> (abbreviate-file-name "d:/usr/eli/foo/bar") => "~/foo/bar"

I see. To tell the truth, I didn't bother to change \$HOME outside Emacs and
start emacs -Q again to test the case other than HOME = "c:\\". I did try
using `setenv' to change "HOME", but that apparently doesn't have an effect
here. That is:

(setenv "HOME" "d:/usr/eli")
(abbreviate-file-name "d:/usr/eli/foo/bar") => "d:/usr/eli/foo/bar"

So, I didn't notice that it does work properly. Setting \$HOME in Windows
itself to "d:\eli\" and then starting emacs -Q, I do get what you showed:

(abbreviate-file-name "d:/usr/eli/foo/bar") => "~/foo/bar"

So, I was mistaken - no problem. Thx for the clear explanation.

How about mentioning in the doc string that "~" is not substituted for the
user's home dir if that is the root. ("/" in Unix or Linux,
"<drive-letter>:\" in Windows)? The doc string gives an incorrect idea of
what the function does, in this case (which is common in Windows).

```