Subject: Re: bug#51650: Autocomplete: first Tab should show *Completions* buffer

From: Carlos Pita <[email-masked]>
Date: Sun, 7 Nov 2021 18:24:56 -0300

On Sun, Nov 7, 2021 at 5:39 PM Eli Zaretskii <[email-masked]> wrote:

> > - The initial value is taken from the current working directory so
> > it's always a valid completion.
>
> The completion doesn't know that.  It's just what the caller arranged
> for it to display.
> [...]
> The completion doesn't know where it was launched from.  It just knows
> what the user typed, and in the "~/" case the user didn't type
> anything.

If we add the context that we're doing directory completion from the
cwd my statement is true. If we remove that context I start to see
where you're coming from. Let's say the algorithm is more generic and
unaware of some facts like its initial value being valid. From its
perspective it may start with an invalid response that's not even a
prefix of a valid response. After the TAB that goes from ~/Desk to
~/Desktop/ at least it knows that the response is the prefix of some
set of valid completions. So you may explain its behavior as:

1. C-x C-f => ~/ but from what I know this may be rubbish
2. TAB => ~/ ok this is a completion but there are more with the same prefix
3. TAB => ~/ as I said there are more with the same prefix, take a
look at the other ones
4. Desk<TAB> => ~/Desktop/ ok this is a completion
5. TAB => ~/Desktop/ there are more with the same prefix, take a look
at the other ones

At this level of explanation, there is a difference between the TAB in
2 and the TAB in 5. I also get why you may be willing to say that from
1 to 2 a completion indeed happened when, on the face of it, this
seems a nonsensical statement: the algorithm inspected a completion
set at this point and realized that the initial value is a member of
it. It's hardly what the manual conveys to a user unaware of the
implementation, but I get it. I still don't get why 2 and 3 can't be
merged into a single step but that would be a discussion about
convenience, at least I'm satisfied with this logical tackle on the
inconsistency issue.