emacs-diffs
[Top][All Lists]
Advanced

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

master 01912a0679e: * lisp/minibuffer.el (minibuffer-choose-completion-o


From: Juri Linkov
Subject: master 01912a0679e: * lisp/minibuffer.el (minibuffer-choose-completion-or-exit): New command.
Date: Wed, 8 Nov 2023 02:39:01 -0500 (EST)

branch: master
commit 01912a0679ea3feb48fdde4dab372c056bce446e
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/minibuffer.el (minibuffer-choose-completion-or-exit): New command.
    
    (minibuffer-visible-completions-map): Bind it to "RET".
    https://lists.gnu.org/archive/html/emacs-devel/2023-11/msg00246.html
---
 lisp/minibuffer.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 7a791fafaa6..bf1e014319e 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3000,7 +3000,7 @@ displaying the *Completions* buffer exists."
   "<right>" (minibuffer-visible-completions-bind #'minibuffer-next-completion)
   "<up>"    (minibuffer-visible-completions-bind 
#'minibuffer-previous-line-completion)
   "<down>"  (minibuffer-visible-completions-bind 
#'minibuffer-next-line-completion)
-  "RET"     (minibuffer-visible-completions-bind 
#'minibuffer-choose-completion)
+  "RET"     (minibuffer-visible-completions-bind 
#'minibuffer-choose-completion-or-exit)
   "C-g"     (minibuffer-visible-completions-bind 
#'minibuffer-hide-completions))
 
 
@@ -4682,10 +4682,20 @@ of `completion-no-auto-exit'.
 If NO-QUIT is non-nil, insert the completion candidate at point to the
 minibuffer, but don't quit the completions window."
   (interactive "P")
-    (with-minibuffer-completions-window
+  (with-minibuffer-completions-window
     (let ((completion-use-base-affixes t))
       (choose-completion nil no-exit no-quit))))
 
+(defun minibuffer-choose-completion-or-exit (&optional no-exit no-quit)
+  "Choose the completion from the minibuffer or exit the minibuffer.
+When `minibuffer-choose-completion' can't find a completion candidate
+in the completions window, then exit the minibuffer using its present
+contents."
+  (interactive "P")
+  (condition-case nil
+      (minibuffer-choose-completion no-exit no-quit)
+    (error (exit-minibuffer))))
+
 (defun minibuffer-complete-history ()
   "Complete the minibuffer history as far as possible.
 Like `minibuffer-complete' but completes on the history items



reply via email to

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