Subject: Re: bug#77253: 30.1.50; Support RET choosing the selected completion without rebinding arrow keys

From: Spencer Baugh <[email-masked]>
Date: Thu, 27 Mar 2025 16:42:29 -0400

Juri Linkov <[email-masked]> writes:
>> But, here's another factor: The *Completions* buffer by default contains
>> a help message explaining to users that they can use M-<up> and M-<down>
>> to select completions.  There's no such message explaining to users that
>> they can use C-b/C-f/C-n/C-p to move point.  So:
>>
>> - If the arrow keys move point, users can still figure out how to select
>>   completions by reading the help text.
>>
>> - If the arrow keys select completions, users who don't know
>>   C-b/C-f/C-n/C-p are basically helpless.  (This is sadly common at my
>>   site, because most of our users use evil-mode and don't know
>>   C-b/C-f/C-n/C-p)
>
> When users need to move point with arrow keys, then they have
> to close the completions window.  This is the purpose of
> 'minibuffer-visible-completions': to eliminate ambiguity
> whether arrows/RET apply to the visible completions window,
> or to the text in the minibuffer.

Yes, and I'm definitely a fan of minibuffer-visible-completions, but
just to name a few problems:

- It's not necessarily obvious that closing the completions window will
  make the arrow keys operate in the minibuffer.  Actually, maybe we
  should update the completion help text to say that?  That might help a
  lot.

- The new completion-eager-display makes *Completions* pop up
  immediately; when this happens, it can be surprising that the arrow
  keys don't work in the minibuffer from the very start of the
  minibuffer session.

But again, I like minibuffer-visible-completions a lot, I'm just
wondering about other points in the design space.

>> Also, rebinding the arrow keys by default to select completions is
>> probably an unacceptable behavior change.  But it's very possible to
>> rebind RET to accept completions by default.  So even if we disregard
>> the "novice user" argument, I still think we should investigate binding
>> RET without rebinding the arrow keys.
>
> Not sure if it's possible for RET to accept the selected candidate
> by default since users might prefer to accept text in the minibuffer.

If there's a selected candidate, though, then users have already decided
to use M-<up>/M-<down> to interact with completions.  (Or they've
switched to the completions buffer and selected one)

If they decide they don't want the candidate they selected, and want to
continue with text in the minibuffer, completion-auto-deselect will
automatically deselect the candidate if they type anything.

I think these two facts combined make it possible for RET to accept the
selected candidate by default.

>> I'm curious: Why do you prefer the :filter approach?  Does it avoid some
>> problems that happened in the past?  It makes sense for the arrow keys,
>> but if we are rebinding RET by default, :filter seems like an unusual
>> thing to use.
>
> :filter makes it easier to add conditional keybindings that share
> the same condition.  I doubt if it would be possible to rebind RET
> by default.  But need to try to see how it works.

Makes sense.  I'll try.