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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 09 Dec 2023 15:25:45 +0200

> From: Eshel Yaron <[email-masked]>
> Cc: Juri Linkov <[email-masked]>,  [email-masked],  Eli Zaretskii
>  <[email-masked]>,  [email-masked]
> Date: Sat, 09 Dec 2023 14:08:45 +0100
> 
> 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?

This is not the regression that needs to be fixed here.

> > 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.

Once again, the fact that the second TAB shows both completion
interfaces is not the problem: as you point out that was how Emacs
behaved since long ago.  The problem here is that the _first_ TAB does
NOT show in-buffer completions.  This should be fixed, since it is a
regression wrt Emacs 29.

> 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.

That sounds like some very technical problem, and it should be fixed
by some other means than disabling completion-in-region-mode.

> If it doesn't make sense for `icomplete-in-buffer` to appear along with
> the *Completions* buffer

Again, this is not the problem to solve.