diff options
author | Juri Linkov <juri@linkov.net> | 2022-04-11 19:51:49 +0300 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2022-04-11 19:52:47 +0300 |
commit | 67505e035528c59b76cd838caf05116d2e34043d (patch) | |
tree | 047d1e15b3d80d818c01cf14a7f21bfac9ac0cab | |
parent | 1c28b9ed1a26be5bd3e8e7f3b15cb00d423760c6 (diff) | |
download | emacs-67505e035528c59b76cd838caf05116d2e34043d.tar.gz |
* lisp/minibuffer.el (minibuffer-completion-auto-choose): New defcustom.
(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.
-rw-r--r-- | etc/NEWS | 3 | ||||
-rw-r--r-- | lisp/minibuffer.el | 52 | ||||
-rw-r--r-- | lisp/simple.el | 6 |
3 files changed, 31 insertions, 30 deletions
@@ -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' diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 68b167ccc78..f60af482da2 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -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. diff --git a/lisp/simple.el b/lisp/simple.el index eb657018039..2481d22ad13 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -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.") |