From 2e7a066d564fee63871845533b6aeb0036a4d006 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 11 Feb 2026 15:04:18 +0000 Subject: [PATCH] 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 in bug#62108. (icomplete-show-matches-on-no-input, icomplete-ret): * etc/NEWS: Improve documentation. --- etc/NEWS | 14 ++++++++------ lisp/icomplete.el | 30 +++++++++++++++++++----------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 68b21fee066..076a4e2c15e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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 " " diff --git a/lisp/icomplete.el b/lisp/icomplete.el index b7002fa545b..875c41bd841 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -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 +` ') 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)))