bug#81630: 32.0.50; completions-format 'vertical scrolls the completion window on TAB tapping

Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
On Sat, 15 Aug 2026 13:03:00 +0000 lucas jimenez <[email protected]> wrote:

> Hi.
>
> When setting completions-format to 'vertical
>
> and start TAB tapping the completions window starts scrolling up and
> down even though all the candidates can be seen in the window.
>
> To reproduce do:
> emacs -Q --eval "(setq completions-format 'vertical)"
> `M-x 5x5`  and start tapping TAB key or `M-x minibuffer-`
>
> Workaround: set (completion-auto-select 'second-tab) or
> (completion-auto-select t) or just don't tap TAB.
>
> This behaviour isn't noticed with 'horizontal or 'one-column

This happens because when `completions-format' is 'vertical the
*Completions* buffer ends in a newline, and that makes
`(pos-visible-in-window-p (point-max) window)' in the "normal tab" case
in `completion--in-region-1' return nil, resulting in the window being
scrolled.  The attached patch prevents this scrolling for me; can you
confirm?  But I cannot tell if such a change might have undesirable
consequences; maybe Stefan Monnier (added in CC:) can tell.

Steve Berman
(unnamed) (text/x-patch, 732 B)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 4da651cc450..14840c21da3 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1765,7 +1765,11 @@ completion--in-region-1
             (with-selected-window window (scroll-down))))
          ;; Normal tab
          (t
-          (if (pos-visible-in-window-p (point-max) window)
+          (if (pos-visible-in-window-p
+               (if (eq completions-format 'vertical)
+                   (1- (point-max))     ; Vertical format has final newline.
+                 (point-max))
+               window)
               ;; If end is in view, scroll up to the end.
               (set-window-start window (point-min) nil)
             ;; Else scroll down one screen.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.