Subject: bug#74924: 29.3; Buffer showing manpage jumps back to beginning

From: Eli Zaretskii <[email-masked]>
Date: Sat, 28 Dec 2024 13:39:05 +0200

> Cc: Ture Pålsson <[email-masked]>, [email-masked]
> From: Robert Pluim <[email-masked]>
> Date: Tue, 17 Dec 2024 14:34:37 +0100
> 
> >>>>> On Tue, 17 Dec 2024 13:19:00 +0000, Stefan Kangas <[email-masked]> said:
> 
>     Stefan> found 74924 29.3
>     Stefan> found 74924 31.0.50
>     Stefan> tags 74924 + confirmed
>     Stefan> thanks
> 
>     Stefan> Ture Pålsson <[email-masked]> writes:
> 
>     >> 1. Run in a terminal window. Operating system seems not to matter; I can
>     >> reproduce on both macOS and Linux.
>     >> 
>     >> 2. Set environment variable MANWIDTH to 80 .
>     >> 
>     >> 3. Start Emacs ('emacs -nw -Q').
>     >> 
>     >> 4. Do M-x man, enter the name of some manpage, and type RET.
>     >> 
>     >> 5. Switch to the manpage window (C-x o), and scroll down by typing 'C-v'
>     >> a few times.
>     >> 
>     >> 6. Switch back to the *scratch* window (C-x o again).
>     >> 
>     >> 7. After about a second, the manpage window jumps back to the beginning
>     >> of the buffer.
>     >> 
>     >> My *guess* is that this is related to the changes in commit
>     >> 7e387c9e5265b98dbb3b986f8ab8ac2217052831, but that may well be a red
>     >> herring.
> 
>     Stefan> I can reproduce this on both 29.3 and master on GNU/Linux.
> 
> 
> This code from man.el should be setq-localʼing Man-columns
> unconditionally, I think (itʼs nil by default):
> 
>     (when (or window-system
> 	      (not (or (getenv "MANWIDTH") (getenv "COLUMNS"))))
>       ;; Since the page buffer is displayed beforehand,
>       ;; we can select its window and get the window/frame width.
>       (setq-local Man-columns (Man-columns))
>       (setenv "COLUMNS" (number-to-string Man-columns)))

If this fixes the problem, please install on master, and thanks.