Subject: Re: bug#13033: 24.3.50; regression: read-file-name-internal handles "~" wrong

From: Stefan Monnier <[email-masked]>
Date: Fri, 30 Nov 2012 13:44:53 -0500

>> OK, that makes sense since older versions did not support
>> user-name completion.  Now you say that (read-file-name-internal "~"
>> 'file-exists-p nil) returns "~/dradams/" and I can't understand where
>> the additional slash comes from.
>> Also arguably, "~/" should also be a completion candidate, so 
>> the above calls should not complete to "~dradams/" but to "~"
>> (the common prefix between the two possible completions).

> I cannot speak to why the / is included or why ~ is not considered the common
> prefix.

Then let me state it more clearly: Are you really sure that

  (read-file-name-internal "~" 'file-exists-p nil) returns "~/dradams/"

even though

  (completion--file-name-table "~" 'file-exists-p nil) returns "~dradams/"

?  I ask because read-file-name-internal is defined as:

   (defalias 'read-file-name-internal
     (completion-table-in-turn #'completion--embedded-envvar-table
                               #'completion--file-name-table)

And I don't see where/why completion-table-in-turn would add a /.
I just want to make extra sure that that's indeed the problem, and not
a simple typo.

> And there is no such directory ~dradams either.

Actually, there should be (in the same sense that there is a directory
named ~, i.e. it's a shorthand expanded by Emacs, more specifically by
`expand-file-name').
What does C-x C-f ~dradams/.emacs RET do?  It should open your ~/.emacs file.

> I do not see why user-name completion (whatever that might mean for
> Unix/GNU/Linux file-name completion) is involved at all on Windows.  The user
> login name has nothing to do with the user's home directory.

`expand-file-name's docstring says:

   An initial `~USER/' expands to USER's home directory.

-- Stefan