diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 6ae25b8def..a34a1ddad0 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1422,9 +1503,9 @@ completion--in-region-1 (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 switch + ;; to completions 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) @@ -1439,7 +1520,9 @@ completion--in-region-1 (set-window-start window (point-min) nil) ;; Else scroll down one screen. (with-selected-window window (scroll-up))))) - nil))) + nil) + (when (eq completion-auto-select 'second-tab) + (switch-to-completions)))) ;; If we're cycling, keep on cycling. ((and completion-cycling completion-all-sorted-completions) (minibuffer-force-complete beg end) @@ -2421,7 +2504,9 @@ minibuffer-completion-help (display-completion-list completions nil group-fun))))) nil))) - nil)) + nil) + (when (eq completion-auto-select t) + (switch-to-completions))) (defun minibuffer-hide-completions () "Get rid of an out-of-date *Completions* buffer." diff --git a/lisp/simple.el b/lisp/simple.el index d6b7045432..99ac7b812d 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9826,9 +9826,7 @@ completion-setup-function (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)