emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 6a50ff10f7: Choosing a completion with a prefix argument doesn't


From: Juri Linkov
Subject: master 6a50ff10f7: Choosing a completion with a prefix argument doesn't exit the minibuffer
Date: Tue, 5 Apr 2022 14:22:19 -0400 (EDT)

branch: master
commit 6a50ff10f7aadb1ec0daee9081df66215369553b
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    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)
---
 etc/NEWS       |  5 +++++
 lisp/simple.el | 16 ++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 640e18c6bd..b567caedb3 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 7918767a75..e49a0ff0f6 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]