Subject: Re: bug#60264: 29.0.60; Strange file completion candidates for shadowed file paths

From: Gregory Heytings <[email-masked]>
Date: Fri, 23 Dec 2022 17:38:08 +0000

>>> 1. Start emacs -Q
>>> 2. C-x C-f
>>> 3. Delete the entire minibuffer input
>>> 4. Enter /etc//s
>>> 5. Press ?
>>>
>>> You will see candidates like etc//sbin/. The candidates can get even 
>>> stranger. If you enter /etc//etc//etc/s then you will get candidates 
>>> like etc//etc//etc//sbin/. I can reproduce this bug on 27 and 29. I 
>>> haven't tried 28, but the issue should exist there too.
>>
>> I don't think it's a bug (look at what the minibuffer shows in those 
>> cases), perhaps just a minor aesthetic thing, but I'm adding Stefan in 
>> case he has comments.
>
> He's right, that's a bug.  *Completions* normally only shows the list of 
> matching files in the final directory, so complete filenames.  It's even 
> more true here where the "excess" is not even really part of the file 
> name since it'll be stripped away by `substitute-in-file-name`.
>
> E.g. if you replace "/etc//s" with "~//s" in the example, we show the 
> correct list.
>

It's a bug indeed, but a very old one, it's also present in Emacs 
24-25-26-27-28.