From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#74924: 29.3; Buffer showing manpage jumps back to beginning Date: Mon, 06 Jan 2025 21:18:10 +0200 Organization: LINKOV.NET Message-ID: <87ed1fvjil.fsf@mail.linkov.net> References: <87seqm302a.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4207"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: martin rudalics , Ture =?UTF-8?Q?P=C3=A5lsson?= , Stefan Kangas , 74924@debbugs.gnu.org To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 06 20:26:18 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tUsjx-0000rf-F6 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Jan 2025 20:26:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUsjl-0006aj-VU; Mon, 06 Jan 2025 14:26:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tUsjj-0006XU-3q for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 14:26:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUsji-0008Fv-Rc for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 14:26:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=gdwuDbl2ENqaXhj1z4xblidkQL2vc+plc0YmDwUQMjo=; b=nwuKgqBVnk2w2jV1tJi9Ks2XdQtAW0BISQ/zRgUf0+/6xkZOT+FLQeV2da3YGddscU2w1y3U7fMGuZPXjMs/zGfaBb4dSWMAS+HcDDiJP4XvkTt6+JONroAo7c75ZEFUDcDT8K1YCuZ+rTTZ0nJRrwzEUcqPegL4ljkjeKNu38Z5rXa0E1vJQC1tIX0eO/BMv9kVvd7Pj+1hTuty80VO7J1bdGm6L4SBZfMJRAvHk9jYMD1RBGwKQuCSQ7MkE2Vw0WT0wrKV842I54kOstchaaHjjgWdZmxGheeQhJVaFVGaYotboo/qnb/wXEhs5kBAnrIcRAbDAZCJeYYK7d7L4g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tUsji-0006AU-Lg for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 14:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Jan 2025 19:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74924 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch confirmed Original-Received: via spool by 74924-submit@debbugs.gnu.org id=B74924.173619152923643 (code B ref 74924); Mon, 06 Jan 2025 19:26:02 +0000 Original-Received: (at 74924) by debbugs.gnu.org; 6 Jan 2025 19:25:29 +0000 Original-Received: from localhost ([127.0.0.1]:40131 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tUsjA-00069G-Vz for submit@debbugs.gnu.org; Mon, 06 Jan 2025 14:25:29 -0500 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:43003) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tUsj8-00068z-L0 for 74924@debbugs.gnu.org; Mon, 06 Jan 2025 14:25:27 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 9679F60002; Mon, 6 Jan 2025 19:25:17 +0000 (UTC) In-Reply-To: <87seqm302a.fsf@gmail.com> (Robert Pluim's message of "Tue, 17 Dec 2024 14:34:37 +0100") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298691 Archived-At: > 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)))