1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Support completion-eager-display in completing-read-multiple

Make completing-read-multiple do eager display of *Completions*
when the table requests it.

As a side-effect of the implementation, we now check again if
eager-display is enabled if we have to retry doing eager-display
due to being interrupted by user input.  This is mildly nicer
since it gives the completion table a little more control: for
example, maybe the table only wants to do eager-display if the
minibuffer is empty; this change makes that work better.

* lisp/minibuffer.el (completions--start-eager-display)
(completing-read-default): Move the code for checking whether to
do eager-display into completions--start-eager-display.
* lisp/emacs-lisp/crm.el (completing-read-multiple): Call
completions--start-eager-display (bug#79858).
This commit is contained in:
Spencer Baugh 2025-11-18 13:28:29 -05:00 committed by Juri Linkov
parent 43bcf3c43b
commit e576dc7556
2 changed files with 16 additions and 16 deletions

View file

@ -285,7 +285,8 @@ with empty strings removed."
(unless (eq require-match t) require-match))
(setq-local minibuffer--require-match require-match)
(setq-local minibuffer--original-buffer buffer)
(setq-local crm-completion-table table))
(setq-local crm-completion-table table)
(completions--start-eager-display))
(setq input (read-from-minibuffer
(format-spec
crm-prompt

View file

@ -2767,9 +2767,19 @@ so that the update is less likely to interfere with user typing."
(completions--start-eager-display))))
(defun completions--start-eager-display ()
"Display the *Completions* buffer when the user is next idle."
"Maybe display the *Completions* buffer when the user is next idle.
Only displays if `completion-eager-display' is t, or if eager display
has been requested by the completion table."
(when completion-eager-display
(when (or (eq completion-eager-display t)
(completion-metadata-get
(completion-metadata
(buffer-substring-no-properties (minibuffer-prompt-end) (point))
minibuffer-completion-table minibuffer-completion-predicate)
'eager-display))
(setq completion-eager-display--timer
(run-with-idle-timer 0 nil #'completions--eager-display)))
(run-with-idle-timer 0 nil #'completions--eager-display)))))
(defun completions--post-command-update ()
"Update displayed *Completions* buffer after command, once."
@ -5159,18 +5169,7 @@ See `completing-read' for the meaning of the arguments."
(setq-local minibuffer--original-buffer buffer)
;; Copy the value from original buffer to the minibuffer.
(setq-local completion-ignore-case c-i-c)
;; Show the completion help eagerly if
;; `completion-eager-display' is t or if eager display
;; has been requested by the completion table.
(when completion-eager-display
(when (or (eq completion-eager-display t)
(completion-metadata-get
(completion-metadata
(buffer-substring-no-properties
(minibuffer-prompt-end) (point))
collection predicate)
'eager-display))
(completions--start-eager-display))))
(completions--start-eager-display))
(read-from-minibuffer prompt initial-input keymap
nil hist def inherit-input-method))))
(when (and (equal result "") def)