]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/minibuffer.el (minibuffer-completion-auto-choose): New defcustom.
authorJuri Linkov <juri@linkov.net>
Mon, 11 Apr 2022 16:51:49 +0000 (19:51 +0300)
committerJuri Linkov <juri@linkov.net>
Mon, 11 Apr 2022 16:52:47 +0000 (19:52 +0300)
(minibuffer-choose-previous-completion)
(minibuffer-choose-next-completion): Remove commands.
(minibuffer-local-completion-map): Remove keybindings of
minibuffer-choose-next-completion and minibuffer-choose-previous-completion.
Use them for minibuffer-next-completion and minibuffer-previous-completion.
* lisp/simple.el (minibuffer-local-shell-command-map): Idem.

etc/NEWS
lisp/minibuffer.el
lisp/simple.el

index 95f52132280111e80c895a74be935f90824e4bf4..3c4dacf9124cc08547cf892fc24a66efeaf63ae3 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -605,7 +605,8 @@ value.
 When the minibuffer is the current buffer, typing 'M-<up>' or
 'M-<down>' selects a previous/next completion candidate from the
 "*Completions*" buffer and inserts it to the minibuffer.
-'M-S-<up>' and 'M-S-<down>' do the same, but without inserting
+When the variable 'minibuffer-completion-auto-choose' is nil,
+'M-<up>' and 'M-<down>' do the same, but without inserting
 a completion candidate to the minibuffer, then 'M-RET' can be used
 to choose the currently active candidate from the "*Completions*"
 buffer and exit the minibuffer.  With a prefix argument, 'C-u M-RET'
index 68b167ccc782b21c5375adce0051d2e1bc4f407f..f60af482da2262c349dba5e2d3163877cc194412 100644 (file)
@@ -2749,11 +2749,9 @@ The completion method is determined by `completion-at-point-functions'."
   "<prior>"   #'switch-to-completions
   "M-v"       #'switch-to-completions
   "M-g M-c"   #'switch-to-completions
-  "M-<up>"    #'minibuffer-choose-previous-completion
-  "M-<down>"  #'minibuffer-choose-next-completion
-  "M-S-<up>"   #'minibuffer-previous-completion
-  "M-S-<down>" #'minibuffer-next-completion
-  "M-RET"      #'minibuffer-choose-completion)
+  "M-<up>"    #'minibuffer-previous-completion
+  "M-<down>"  #'minibuffer-next-completion
+  "M-RET"     #'minibuffer-choose-completion)
 
 (defvar-keymap minibuffer-local-must-match-map
   :doc "Local keymap for minibuffer input with completion, for exact match."
@@ -4356,35 +4354,39 @@ and execute the forms."
        (with-selected-window window
          ,@body))))
 
-(defun minibuffer-previous-completion (&optional n)
-  "Run `previous-completion' from the minibuffer in its completions window."
-  (interactive "p")
-  (with-minibuffer-completions-window
-    (when completions-highlight-face
-      (setq-local cursor-face-highlight-nonselected-window t))
-    (previous-completion (or n 1))))
+(defcustom minibuffer-completion-auto-choose t
+  "Non-nil means to automatically insert completions to the minibuffer.
+When non-nil, then `minibuffer-next-completion' and
+`minibuffer-previous-completion' will insert the completion
+selected by these commands to the minibuffer."
+  :type 'boolean
+  :version "29.1")
 
 (defun minibuffer-next-completion (&optional n)
-  "Run `next-completion' from the minibuffer in its completions window."
+  "Run `next-completion' from the minibuffer in its completions window.
+When `minibuffer-completion-auto-choose' is non-nil, then also
+insert the selected completion to the minibuffer."
   (interactive "p")
   (with-minibuffer-completions-window
     (when completions-highlight-face
       (setq-local cursor-face-highlight-nonselected-window t))
-    (next-completion (or n 1))))
+    (next-completion (or n 1))
+    (when minibuffer-completion-auto-choose
+      (let ((completion-use-base-affixes t))
+        (choose-completion nil t t)))))
 
-(defun minibuffer-choose-previous-completion (&optional n)
+(defun minibuffer-previous-completion (&optional n)
   "Run `previous-completion' from the minibuffer in its completions window.
-Also insert the selected completion to the minibuffer."
-  (interactive "p")
-  (minibuffer-previous-completion n)
-  (minibuffer-choose-completion t t))
-
-(defun minibuffer-choose-next-completion (&optional n)
-  "Run `next-completion' from the minibuffer in its completions window.
-Also insert the selected completion to the minibuffer."
+When `minibuffer-completion-auto-choose' is non-nil, then also
+insert the selected completion to the minibuffer."
   (interactive "p")
-  (minibuffer-next-completion n)
-  (minibuffer-choose-completion t t))
+  (with-minibuffer-completions-window
+    (when completions-highlight-face
+      (setq-local cursor-face-highlight-nonselected-window t))
+    (previous-completion (or n 1))
+    (when minibuffer-completion-auto-choose
+      (let ((completion-use-base-affixes t))
+        (choose-completion nil t t)))))
 
 (defun minibuffer-choose-completion (&optional no-exit no-quit)
   "Run `choose-completion' from the minibuffer in its completions window.
index eb657018039403d70be2feda9d58129d891250a0..2481d22ad13eb31d382d09f813bf3a5cb47e639e 100644 (file)
@@ -3924,10 +3924,8 @@ to the end of the list of defaults just after the default value."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map minibuffer-local-map)
     (define-key map "\t"       #'completion-at-point)
-    (define-key map [M-up]     #'minibuffer-choose-previous-completion)
-    (define-key map [M-down]   #'minibuffer-choose-next-completion)
-    (define-key map [M-S-up]   #'minibuffer-previous-completion)
-    (define-key map [M-S-down] #'minibuffer-next-completion)
+    (define-key map [M-up]     #'minibuffer-previous-completion)
+    (define-key map [M-down]   #'minibuffer-next-completion)
     (define-key map [?\M-\r]   #'minibuffer-choose-completion)
     map)
   "Keymap used for completing shell commands in minibuffer.")