Subject: Re: bug#78944: 31.0.50; Minibuffer completion

From: Stefan Monnier <[email-masked]>
Date: Wed, 23 Jul 2025 09:45:52 -0400

>> Maybe the patch below?  It doesn't actually fix the problem, but with
>> Dani's recipe it adds a message
>>
>>     Switched from style ‘partial-completion’ back to ‘basic’
>>
>> at the end of the minibuffer, to try and explain what's going on.
>
> Thanks. I've just tested your patch, and... I'm sorry to say that I
> don't like the new behavior.

No need to be sorry about it.

> I see that the message (Switched from style ‘partial-completion’ back
> to ‘basic’) appears just after I type the second TAB.  That gives the
> user the impression that something (switching back) happened at that
> moment (when I typed the second TAB).
>
> But IIUC, the style switching (forth and back) all took place when I
> typed the _first_ TAB.  So, I think that, if the user must see some
> message, it should be at that moment (first TAB).

The "something" happens *between* the two, in a sense.
The intention for the message was to explain the behavior of the second
TAB rather than to warn about some potential upcoming behavior.

All in all, I guess we'll have to live with the current confusing
behavior.  The only "real" solution I can see is a way to control which
completion style to use, in a way that's visible to the user.
E.g. after the first TAB, the completion machinery could detect that the
result of the TAB from `partial-completion` would get captured by
`basic`, so it could annotate the result with something that means "use
`partial-completion`".  There are lots of interesting issues here, e.g.:

- The cost of detecting it (requires re-running the completion
  internally a second time right at the end of
  `completion-try-completion`).
- How to display the "use `partial-completion`" thingy.
- How to control when that "use `partial-completion`" thingy actually
  applies.

Maybe the solution starts with a way for the user to control which style
is used when (I occasionally find myself needing to use
`partial-completion` and finding that `basic` gets in the way, so I add
a few `*`s to force `basic` to fail (which is the closest we have
currently to "control which style is used"), which can be frustrated
when the candidates also have `*` in their names 🙁).

        Stefan