Subject: bug#67661: 30.0.50; *Completions* has started popping up for icomplete-in-buffer

From: Eshel Yaron <[email-masked]>
Date: Sat, 09 Dec 2023 14:08:45 +0100

Hi Sean,

Sean Whitton <[email-masked]> writes:

> Previously you would get the icomplete in buffer completion.  Now,
> additionally, *Completions* pops up, but it doesn't make sense to have
> both.

I agree that having both interface together is a bit much, but AFAICT
that has been the case at least since Emacs 27 whenever the text before
point was the longest common prefix of several completion candidates.
For example, try completing "l" instead of "ls" in eshell.  On both
Emacs 27 and on master, this shows both the *Completions* buffer and the
in-buffer `icomplete` interface.  Is this what you get as well?

Sean Whitton <[email-masked]> writes:

> Hello,
>
> On Wed 06 Dec 2023 at 08:41pm +02, Eli Zaretskii wrote:
>
>> AFAICT, the above description of the problem is inaccurate.  The
>> *Completions* buffer would pop up in previous versions as well, but
>> only after a second TAB.  Whereas the in-buffer completion would show
>> after the first TAB.  Now in Emacs 30 after the first TAB nothing
>> happens, and after the second TAB you see the same display as
>> previously after the second TAB: both in-buffer completion and the
>> *Completions* buffer popped up.
>>
>> So I think the problem is that the first TAB does NOT show in-buffer
>> completion anymore in the above scenario.
>
> Commit 5416896d608 is responsible for the problem.
> It would seem that it turns off completion-in-region-mode too early.

IIUC, the problem of showing both interfaces is inherent to how
`icomplete-in-buffer` is implemented.  It's just that in this case of
completing "ls" the *Completions* doesn't show up at first because it's
an exact match.  What allowed the `icomplete` to show up is that
although the *Completions* buffer wasn't shown,
`completion-in-region-mode` would remain on, and that caused only the
`icomplete` interface to appear in this specific case.

The reason we now disable `completion-in-region-mode` when it doesn't
show the *Completions* buffer, is to avoid having the key bindings that
this minor mode sets up from lingering and shadowing other bindings.

If it doesn't make sense for `icomplete-in-buffer` to appear along with
the *Completions* buffer, perhaps `icomplete-in-buffer` should simply be
an alternative `completion-in-region-function`?

Best,

Eshel