icomplete-ret: Ignore icomplete-show-matches-on-no-input

* lisp/icomplete.el (icomplete-ret): No longer conditionalize on
icomplete-show-matches-on-no-input.
Suggested by Juri Linkov <juri@linkov.net> in bug#62108.
(icomplete-show-matches-on-no-input, icomplete-ret):
* etc/NEWS: Improve documentation.
This commit is contained in:
Sean Whitton 2026-02-11 15:04:18 +00:00
parent 90fbadb3b1
commit 2e7a066d56
2 changed files with 27 additions and 17 deletions

View file

@ -3093,12 +3093,14 @@ Meant to be given a global binding convenient to the user. Example:
** Icomplete
*** Change in meaning of 'icomplete-show-matches-on-no-input' (again).
Previously, choosing a different completion with commands like 'C-.'
and then hitting 'RET' would choose the completion under point
when 'icomplete-show-matches-on-no-input' is customized to non-nil.
Doing this will now choose the default value instead. There is
still 'C-j' to choose the completion under point in 'icomplete-mode'.
You can get back the old behavior of the 'RET' key with
For Emacs 28 to Emacs 30, when 'icomplete-show-matches-on-no-input' was
non-nil, 'RET' had special behavior when the minibuffer's contents was
equal to the initial input it had right after minibuffer activation.
In that case, 'RET' would choose the first completion candidate, if
there was one, instead of the minibuffer's default value.
'RET' has now returned to selecting the default value in this case; you
can use 'C-j' to choose the completion under point instead.
You can opt back in to the special behavior of 'RET' like this:
(keymap-set
icomplete-minibuffer-map "<remap> <minibuffer-complete-and-exit>"

View file

@ -79,11 +79,12 @@ selection process starts again from the user's $HOME."
(defcustom icomplete-show-matches-on-no-input nil
"When non-nil, show completions when first prompting for input.
This means to show completions even when the current minibuffer contents
is the same as was the initial input after minibuffer activation.
is the same as the initial input after minibuffer activation.
This also means that if you just hit \\`C-j' without typing any
characters, the match under point will be chosen instead of the
default. But \\`RET' will still choose the default value exactly
as when this option is nil."
characters, this chooses the first completion candidate instead of the
minibuffer's default value.
See also `icomplete-ret'."
:type 'boolean
:version "24.4")
@ -246,14 +247,21 @@ Used to implement the option `icomplete-show-matches-on-no-input'.")
"C-," #'icomplete-backward-completions)
(defun icomplete-ret ()
"Exit minibuffer for icomplete.
You can bind this command to \\`RET' in `icomplete-minibuffer-map',
or remap from `minibuffer-complete-and-exit', to be able to choose
the completion under point with \\`RET' instead of choosing the
default value."
"Alternative minibuffer exit for Icomplete.
If there is a completion candidate and the minibuffer contents is the
same as it was right after minibuffer activation, exit selecting that
candidate. Otherwise do as `minibuffer-complete-and-exit'.
You may wish to consider binding this command to \\`RET' (or to
`<remap> <minibuffer-complete-and-exit>') in `icomplete-minibuffer-map'.
If you do that, then when Emacs first prompts for input such that the
current minibuffer contents is equal to the initial input right after
minibuffer activation, \\`RET' chooses the first completion candidate
instead of the minibuffer's default value.
This rebinding is especially useful if you have customized
`icomplete-show-matches-on-no-input' to a non-nil value."
(interactive)
(if (and icomplete-show-matches-on-no-input
(car completion-all-sorted-completions)
(if (and (car completion-all-sorted-completions)
(equal (icomplete--field-string) icomplete--initial-input))
(icomplete-force-complete-and-exit)
(minibuffer-complete-and-exit)))