]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/minibuffer.el (minibuffer-choose-completion-or-exit): New command.
authorJuri Linkov <juri@linkov.net>
Wed, 8 Nov 2023 07:38:35 +0000 (09:38 +0200)
committerJuri Linkov <juri@linkov.net>
Wed, 8 Nov 2023 07:38:35 +0000 (09:38 +0200)
(minibuffer-visible-completions-map): Bind it to "RET".
https://lists.gnu.org/archive/html/emacs-devel/2023-11/msg00246.html

lisp/minibuffer.el

index 7a791fafaa65cc4e60da7f74dd34c4b3c5c0c3fc..bf1e014319e09b7e29d61e70cea399e42b2c3768 100644 (file)
@@ -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))
 
 \f
@@ -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