(let ((window minibuffer-scroll-window))
(with-current-buffer (window-buffer window)
(cond
- ;; Here this is possible only when second-tab, so jump now.
- (completion-auto-select
- (switch-to-completions))
+ ;; Here this is possible only when second-tab, but instead of
+ ;; scrolling the completion list window, switch to it below,
+ ;; outside of `with-current-buffer'.
+ ((eq completion-auto-select 'second-tab))
;; Reverse tab
((equal (this-command-keys) [backtab])
(if (pos-visible-in-window-p (point-min) window)
;; If end is in view, scroll up to the end.
(set-window-start window (point-min) nil)
;; Else scroll down one screen.
- (with-selected-window window (scroll-up)))))
- nil)))
+ (with-selected-window window (scroll-up))))))
+ (when (eq completion-auto-select 'second-tab)
+ (switch-to-completions))
+ nil))
;; If we're cycling, keep on cycling.
((and completion-cycling completion-all-sorted-completions)
(minibuffer-force-complete beg end)
t)
- (t (pcase (completion--do-completion beg end)
- (#b000 nil)
- (_ t)))))
+ (t (prog1 (pcase (completion--do-completion beg end)
+ (#b000 nil)
+ (_ t))
+ (when (and (eq completion-auto-select t)
+ (window-live-p minibuffer-scroll-window)
+ (eq t (frame-visible-p (window-frame minibuffer-scroll-window))))
+ ;; When the completion list window was displayed, select it.
+ (switch-to-completions))))))
(defun completion--cache-all-sorted-completions (beg end comps)
(add-hook 'after-change-functions
When the value is t, pressing TAB will switch to the completion list
buffer when Emacs pops up a window showing that buffer.
If the value is `second-tab', then the first TAB will pop up the
-window shwoing the completions list buffer, and the next TAB will
+window showing the completions list buffer, and the next TAB will
switch to that window.
See `completion-auto-help' for controlling when the window showing
the completions is popped up and down."
:type '(choice (const :tag "Don't auto-select completions window" nil)
(const :tag "Select completions window on first TAB" t)
- (const :tag
- "Select completions window on second TAB" second-tab))
+ (const :tag "Select completions window on second TAB"
+ second-tab))
:version "29.1"
:group 'completion)
;; If at the last completion option, wrap or skip
;; to the minibuffer, if requested.
(when completion-wrap-movement
- (if (and (eq completion-auto-select t) tabcommand)
+ (if (and (eq completion-auto-select t) tabcommand
+ (minibufferp completion-reference-buffer))
(throw 'bound nil)
(first-completion))))
(setq n (1- n)))
;; If at the first completion option, wrap or skip
;; to the minibuffer, if requested.
(when completion-wrap-movement
- (if (and (eq completion-auto-select t) tabcommand)
+ (if (and (eq completion-auto-select t) tabcommand
+ (minibufferp completion-reference-buffer))
(progn
- ;; (goto-char (next-single-property-change (point) 'mouse-face))
(throw 'bound nil))
(last-completion))))
(setq n (1+ n))))
(insert "Click on a completion to select it.\n"))
(insert (substitute-command-keys
"In this buffer, type \\[choose-completion] to \
-select the completion near point.\n\n")))))
- (when (eq completion-auto-select t)
- (switch-to-completions)))
+select the completion near point.\n\n"))))))
(add-hook 'completion-setup-hook #'completion-setup-function)