Update 'crm-complete-and-exit' from 'minibuffer-complete-and-exit'

* lisp/emacs-lisp/crm.el (crm-complete-and-exit):
Add new arg 'no-exit'.  Call 'minibuffer-choose-completion'
when 'completion--selected-candidate' returns non-nil (bug#80821).
This commit is contained in:
Juri Linkov
2026-04-16 20:12:03 +03:00
parent 126eab79b0
commit d88e73d047

View File

@@ -192,14 +192,21 @@ Like `minibuffer-complete-word' but for `completing-read-multiple'."
(crm--completion-command beg end
(completion-in-region--single-word beg end)))
(defun crm-complete-and-exit ()
(defun crm-complete-and-exit (&optional no-exit)
"If all of the minibuffer elements are valid completions then exit.
All elements in the minibuffer must match. If there is a mismatch, move point
to the location of mismatch and do not exit.
If a completion candidate is selected in the *Completions* buffer, it
will be inserted in the minibuffer first. If NO-EXIT is non-nil, don't
actually exit the minibuffer, just insert the selected completion if
any.
This function is modeled after `minibuffer-complete-and-exit'."
(interactive)
(let ((doexit t))
(interactive "P")
(when (completion--selected-candidate)
(minibuffer-choose-completion t t))
(let ((doexit (not no-exit)))
(goto-char (minibuffer-prompt-end))
(while
(and doexit