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
This commit is contained in:
parent
2f68673a71
commit
b2a5bf142f
3 changed files with 26 additions and 21 deletions
|
@ -1439,9 +1439,13 @@ performs completion using the function, variable, or property names
|
|||
defined in the current Emacs session.
|
||||
|
||||
In all other respects, in-buffer symbol completion behaves like
|
||||
minibuffer completion. For instance, if Emacs cannot complete to a
|
||||
unique symbol, it displays a list of completion alternatives in
|
||||
another window. @xref{Completion}.
|
||||
minibuffer completion. For instance, if Emacs cannot complete to
|
||||
a unique symbol, it displays a list of completion alternatives in
|
||||
another window. Then you can use the keys @kbd{M-@key{DOWN}} and
|
||||
@kbd{M-@key{UP}} to navigate through the completions displayed
|
||||
in the completions buffer without leaving the original buffer,
|
||||
and the key @kbd{M-@key{RET}} to insert the currently highlighted
|
||||
completion to the buffer. @xref{Completion}.
|
||||
|
||||
In Text mode and related modes, @kbd{M-@key{TAB}} completes words
|
||||
based on the spell-checker's dictionary. @xref{Spelling}.
|
||||
|
|
4
etc/NEWS
4
etc/NEWS
|
@ -977,7 +977,9 @@ 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'
|
||||
inserts the currently active candidate to the minibuffer, but doesn't
|
||||
exit the minibuffer.
|
||||
exit the minibuffer. These keys are also available for in-buffer
|
||||
completion, but they don't insert candidates automatically, you need
|
||||
to type 'M-RET' to insert the selected candidate to the buffer.
|
||||
|
||||
+++
|
||||
*** The "*Completions*" buffer can now be automatically selected.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue