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}.
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.
;; 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:
(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)))
: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.