From: Juri Linkov Date: Tue, 5 Apr 2022 18:21:42 +0000 (+0300) Subject: Choosing a completion with a prefix argument doesn't exit the minibuffer X-Git-Tag: emacs-29.0.90~1931^2~760 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6a50ff10f7aadb1ec0daee9081df66215369553b;p=emacs.git Choosing a completion with a prefix argument doesn't exit the minibuffer * lisp/simple.el (choose-completion): New optional args NO-EXIT and NO-QUIT. (bug#47417) --- diff --git a/etc/NEWS b/etc/NEWS index 640e18c6bdc..b567caedb35 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -645,6 +645,11 @@ When this user option names a face, the current candidate in the "*Completions*" buffer is highlighted with that face. The nil value disables this highlighting. +*** Choosing a completion with a prefix argument doesn't exit the minibuffer. +This means that typing 'C-u RET' on a completion candidate in the +"*Completions*" buffer inserts the completion to the minibuffer, +bot doesn't exit the minibuffer. + ** Isearch and Replace +++ diff --git a/lisp/simple.el b/lisp/simple.el index 7918767a756..e49a0ff0f65 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9229,10 +9229,16 @@ backward)." (when (/= 0 n) (switch-to-minibuffer)))) -(defun choose-completion (&optional event) +(defun choose-completion (&optional event no-exit no-quit) "Choose the completion at point. -If EVENT, use EVENT's position to determine the starting position." - (interactive (list last-nonmenu-event)) +If EVENT, use EVENT's position to determine the starting position. +With prefix argument NO-EXIT, insert the completion at point to the +minibuffer, but don't exit the minibuffer. When the prefix argument +is not provided, then whether to exit the minibuffer depends on the value +of `completion-no-auto-exit'. +If NO-QUIT is non-nil, insert the completion at point to the +minibuffer, but don't quit the completions window." + (interactive (list last-nonmenu-event current-prefix-arg)) ;; In case this is run via the mouse, give temporary modes such as ;; isearch a chance to turn off. (run-hooks 'mouse-leave-buffer-hook) @@ -9240,6 +9246,7 @@ If EVENT, use EVENT's position to determine the starting position." (let ((buffer completion-reference-buffer) (base-position completion-base-position) (insert-function completion-list-insert-choice-function) + (completion-no-auto-exit (if no-exit t completion-no-auto-exit)) (choice (save-excursion (goto-char (posn-point (event-start event))) @@ -9257,7 +9264,8 @@ If EVENT, use EVENT's position to determine the starting position." (unless (buffer-live-p buffer) (error "Destination buffer is dead")) - (quit-window nil (posn-window (event-start event))) + (unless no-quit + (quit-window nil (posn-window (event-start event)))) (with-current-buffer buffer (choose-completion-string