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

From: Juri Linkov <[email-masked]>
Date: Thu, 03 Apr 2025 21:19:16 +0300

>>> - 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.
>>
>> Maybe it's possible to squeeze this help text just into one additional line?
>> Something like:
>>
>>   Type 'C-g' to close this window and restore arrows to move point.
>
> Maybe we don't even need an additional line?  How about:
>
> Click or type RET on a completion to select it, or C-g to close this window.
> Type <right>, <left>, <down>, <up> to move point between completions.

Looks good.

>>> - 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.
>>
>> Then another possible value for 'minibuffer-visible-completions'
>> would be to not rebind left/right arrows when the completions window
>> contains only one column (like on the browser's address bar).
>
> True.  Though I guess that could maybe be the default behavior when
> completions-format=one-column.

Agreed.

>>>> 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.
>>
>> Makes sense.  So we need to try how well it performs.
>
> How about this?

Thanks, will try to use for a while.

> (BTW, after writing minibuffer--completions-visible, I'm wondering if
> most of the code which calls (get-buffer-window "*Completions*" 0) is
> actually buggy, because it's not checking completion-reference-buffer.
> Should we replace ~all the calls to (get-buffer-window "*Completions*"
> 0) with (minibuffer--completions-visible) which does check that?)

Looks right, for example for the case of recursive minibuffers.

> +      (minibuffer-exit)))

Typo: 'exit-minibuffer'.