summaryrefslogtreecommitdiff
path: root/lisp/minibuffer.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2022-05-22 20:55:35 +0300
committerJuri Linkov <juri@linkov.net>2022-05-22 20:55:35 +0300
commitb2a5bf142fb25094ff623dc93d2ce916aee3d971 (patch)
tree208403e4628c7149f48ca9fa4e648cd600d6847b /lisp/minibuffer.el
parent2f68673a712508f70de20f485422c7e01b8ab21b (diff)
downloademacs-b2a5bf142fb25094ff623dc93d2ce916aee3d971.tar.gz
Enable keys M-down, M-up, M-RET for in-buffer completion
* lisp/minibuffer.el (completion-in-region-mode-map): Add keybindings M-<up> for minibuffer-previous-completion, M-<down> for minibuffer-next-completion, M-RET for minibuffer-choose-completion. (completion-in-region-mode): Set buffer-local 'minibuffer-completion-auto-choose' to nil. (minibuffer-next-completion): Get the value of 'minibuffer-completion-auto-choose' from the minibuffer. (minibuffer-previous-completion): Simplify by delegating to 'minibuffer-next-completion'. * doc/emacs/programs.texi (Symbol Completion): Add description of keys M-down, M-up, M-RET. https://lists.gnu.org/archive/html/emacs-devel/2022-05/msg00916.html
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r--lisp/minibuffer.el33
1 files changed, 16 insertions, 17 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index fb473cf71b0..ee00f96b520 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2543,7 +2543,10 @@ Also respects the obsolete wrapper hook `completion-in-region-functions'.
;; FIXME: Only works if completion-in-region-mode was activated via
;; completion-at-point called directly.
"M-?" #'completion-help-at-point
- "TAB" #'completion-at-point)
+ "TAB" #'completion-at-point
+ "M-<up>" #'minibuffer-previous-completion
+ "M-<down>" #'minibuffer-next-completion
+ "M-RET" #'minibuffer-choose-completion)
;; It is difficult to know when to exit completion-in-region-mode (i.e. hide
;; the *Completions*). Here's how previous packages did it:
@@ -2590,6 +2593,7 @@ Also respects the obsolete wrapper hook `completion-in-region-functions'.
(cl-assert completion-in-region-mode-predicate)
(setq completion-in-region-mode--predicate
completion-in-region-mode-predicate)
+ (setq-local minibuffer-completion-auto-choose nil)
(add-hook 'post-command-hook #'completion-in-region--postch)
(push `(completion-in-region-mode . ,completion-in-region-mode-map)
minor-mode-overriding-map-alist)))
@@ -4369,30 +4373,25 @@ selected by these commands to the minibuffer."
:version "29.1")
(defun minibuffer-next-completion (&optional n)
- "Run `next-completion' from the minibuffer in its completions window.
+ "Move to the next item in its completions window from the minibuffer.
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))
- (when minibuffer-completion-auto-choose
- (let ((completion-use-base-affixes t))
- (choose-completion nil t t)))))
+ (let ((auto-choose minibuffer-completion-auto-choose))
+ (with-minibuffer-completions-window
+ (when completions-highlight-face
+ (setq-local cursor-face-highlight-nonselected-window t))
+ (next-completion (or n 1))
+ (when auto-choose
+ (let ((completion-use-base-affixes t))
+ (choose-completion nil t t))))))
(defun minibuffer-previous-completion (&optional n)
- "Run `previous-completion' from the minibuffer in its completions window.
+ "Move to the previous item in its completions window from the minibuffer.
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))
- (previous-completion (or n 1))
- (when minibuffer-completion-auto-choose
- (let ((completion-use-base-affixes t))
- (choose-completion nil t t)))))
+ (minibuffer-next-completion (- (or n 1))))
(defun minibuffer-choose-completion (&optional no-exit no-quit)
"Run `choose-completion' from the minibuffer in its completions window.