From d88e73d047367bc76e4ecec7fdd00c70d7d4ea13 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 16 Apr 2026 20:12:03 +0300 Subject: [PATCH] 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). --- lisp/emacs-lisp/crm.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el index a1c7175fc66..39a01490365 100644 --- a/lisp/emacs-lisp/crm.el +++ b/lisp/emacs-lisp/crm.el @@ -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