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

From: Spencer Baugh <[email-masked]>
Date: Wed, 26 Mar 2025 10:06:20 -0400

Juri Linkov <[email-masked]> writes:

>>>> Right now, minibuffer-visible-completions does two things, only when
>>>> *Completions* is visible:
>>>>
>>>> A. If there's a selected completion candidate, RET exits the minibuffer
>>>> with it.
>>>>
>>>> B. The arrow keys move point in the *Completions* buffer instead of the
>>>> minibuffer, to select completion candidates.
>>>>
>>>> These are really two separate things.
>>>>
>>>> A is a nice behavior for novice users, but B is difficult for novice
>>>> users (who like to use the arrow keys for moving point) to deal with.
>>>
>>> Not sure why this would be difficult for novice users,
>>
>> Well, because they like using the arrow keys. :)
>
> But they like using the arrow keys to select a completion candidate too.
> This is how they use arrow keys e.g. in a web browser in the address bar.
> At least up/down arrows navigate completions, while left/right arrows
> indeed move the cursor in the address bar.

That is true.

> So we need separate values for up/down and left/right arrows?

That would probably be good, yes.

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)

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.

>>> but maybe adding a new value to the existing defcustom
>>> minibuffer-visible-completions would be sufficient?
>>
>> That would work, but I guess I also propose that we should change the
>> implementation a bit.  The use of a menu-item :filter binding is clever,
>> but I think it would be nicer to have a normal binding for RET which
>> just checks if *Completions* is shown/a completion candidate is
>> selected.  For one thing, then C-h k RET will behave more expectedly.
>
> Removing the :filter binding would be fine, if it won't cause other problems.
> At least it would be nice to try to see how this works with :filter.

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.