GNU bug report logs - #74924
29.3; Buffer showing manpage jumps back to beginning

Previous Next

Package: emacs;

Reported by: Ture Pålsson <ture <at> turepalsson.se>

Date: Tue, 17 Dec 2024 09:08:01 UTC

Severity: minor

Tags: confirmed

Found in versions 29.3, 31.0.50

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: martin rudalics <rudalics <at> gmx.at>, Ture Pålsson <ture <at> turepalsson.se>, Stefan Kangas <stefankangas <at> gmail.com>, 74924 <at> debbugs.gnu.org
Subject: bug#74924: 29.3; Buffer showing manpage jumps back to beginning
Date: Mon, 06 Jan 2025 21:18:10 +0200
> 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)))

The problem is that the number returned by '(Man-columns)'
is inapplicable in case of "MANWIDTH".

So I will add a check for 'Man-columns' like below.

However, before pushing the patch, let's solve another problem
that the manpage window jumps back to the beginning
even on a window system.  Here is the reproducible test case:

1. emacs -Q
2. M-x man RET man RET
3. C-M-v (scroll-other-window)
4. Reduce the width of the frame
5. manpage window jumps back to the beginning

So unless Martin has objections, I will also change
'with-current-buffer' to 'with-selected-window':

diff --git a/lisp/man.el b/lisp/man.el
index 29c3dec501c..ba4f01122e2 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1300,8 +1300,9 @@ Man--window-state-change
 (defun Man-fit-to-window (window)
   "Adjust width of the buffer to fit columns into WINDOW boundaries."
   (when (window-live-p window)
-    (with-current-buffer (window-buffer window)
+    (with-selected-window window
       (when (and (derived-mode-p 'Man-mode)
+                 Man-columns
                  (not (eq Man-columns (Man-columns))))
         (let ((proc (get-buffer-process (current-buffer))))
           (unless (and proc (not (eq (process-status proc) 'exit)))




This bug report was last modified 127 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.