From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Steven Allen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72323: 31.0.50; line-move unconditionally resets vscroll to 0 Date: Sat, 27 Jul 2024 13:10:03 -0700 Message-ID: <87v80qha04.fsf@stebalien.com> References: <87zfq2hg4n.fsf@stebalien.com> <86ikwq1z92.fsf@gnu.org> Reply-To: Steven Allen Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11169"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72323@debbugs.gnu.org, storm@cua.dk To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 27 22:11:16 2024 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 1sXnl4-0002i0-Nb for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Jul 2024 22:11:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sXnkk-000851-CI; Sat, 27 Jul 2024 16:10:54 -0400 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 1sXnki-00084i-Gc for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 16:10:52 -0400 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 1sXnki-000317-7h for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 16:10:52 -0400 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=FM1vg5N6bDZYAhUek1uCsu7rH8K7EOpLGbwOaxv2CKA=; b=ExsidSsKdh1D7bmu8EO04ft+d1thX6hGcxKv8ScCsc/OnEaFth/Sz71llTKdqaPBkYWyAePUN8mBukg6u9p3z47O9RMQjiwRamsSj/1IfdZSDCmM7TfFyr+QAc59wLNTlGr0oUf/McFbMUQ1JOd1G6F5xCXUhEYXmMcqodWltaTm1QbEWBcrxA9IjtD4aKSrj7mRcocH2pRX374dCs9pf8ELJiHJbEBEZY5wtWlKKTXQ0GW/GeDqjOrMgHEkjhgdC5z2TOSmqczKNxOMxQk+PYQkdXcTej9WQ+IxUyi4xS5OirEfTIs3cMdLVum8re09FUs4LKMSYM/VDAXN53m37g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sXnks-0006Uz-Cu for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 16:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Steven Allen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Jul 2024 20:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72323 X-GNU-PR-Package: emacs Original-Received: via spool by 72323-submit@debbugs.gnu.org id=B72323.172211103224937 (code B ref 72323); Sat, 27 Jul 2024 20:11:02 +0000 Original-Received: (at 72323) by debbugs.gnu.org; 27 Jul 2024 20:10:32 +0000 Original-Received: from localhost ([127.0.0.1]:42454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sXnkN-0006U8-EJ for submit@debbugs.gnu.org; Sat, 27 Jul 2024 16:10:32 -0400 Original-Received: from fout1-smtp.messagingengine.com ([103.168.172.144]:46895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sXnkK-0006Ts-43 for 72323@debbugs.gnu.org; Sat, 27 Jul 2024 16:10:29 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 5EA2E138011D; Sat, 27 Jul 2024 16:10:09 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 27 Jul 2024 16:10:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stebalien.com; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1722111009; x= 1722197409; bh=FM1vg5N6bDZYAhUek1uCsu7rH8K7EOpLGbwOaxv2CKA=; b=w EYPvHpV2qiECJz8c9kZ8uQCQH6gsun7rMvvgsXf8j6FoZe6f1QL5ZrcUqUnZgASp JDO9l5+5/SCzRUZrSIcjUmQQoJHfaZpyjAA0vv0WNe/U8vin0Gbx9+G/TvPaNhzA fqIjiEYE6cPOG0ePV9OXERt8eWWy/Hm6c6c8yoO/6CC5x9A//2Onk73De4KifYDf 6n9kErjTtESMzr86Qv3a6aXI1Heah64uT1qV1FOtLeCVuMAXIc8zD/sFPj5ONzKn Y3KSEWB43BDW0ddqVjU6r39iYMOc5ZL/yLu0uCuPyG1dKUACJmE5v7QJDUEeHCpa HuDDcoGZ1BybJWQIZeUMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1722111009; x=1722197409; bh=FM1vg5N6bDZYAhUek1uCsu7rH8K7 EOpLGbwOaxv2CKA=; b=GRND/hjFV840uE6zXdKVZPW91ay8vKmZIWoU0DDtZhGV wmq1U0XAFpaTrmeV+a3/7+TCVKLvgypCHDk59AFQG3advhZs+VdwS7Yv8/3+jfJ3 yfBe+6L7v8M2XH09hdfn8YP2wBe7BzDQHucPFXeQHSP4r25NIm5Ief+qn8f5x7KY 0ftdEcV9K6278/dodTo6p60w9UsPIs+FoprRKOmX5t9qsk0/5mqLHmyBJoYEQb5V qgxjRfg/nE20taNLcRTuNTlVSUCl8yca0ZvlS8CkUh31qxC/84Hvp9dkWZYG6Z6M vXzebcLTi5r4UQy/d6QMYwUgRUQGtly79vOkdqPr8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrieejgddugeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefujghffffkgggtsehmtderredttddtnecuhfhrohhmpefuthgvvhgv nhcutehllhgvnhcuoehsthgvvhgvnhesshhtvggsrghlihgvnhdrtghomheqnecuggftrf grthhtvghrnhepjedufedvieejueektddtgedugeffveejheehieeulefgfffhleffheef vefhvdegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshhtvghvvghnsehsthgvsggrlhhivghnrdgtohhmpdhnsggprhgtphhtthhopedt X-ME-Proxy: Feedback-ID: ie8a146a7:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 27 Jul 2024 16:10:08 -0400 (EDT) In-Reply-To: <86ikwq1z92.fsf@gnu.org> 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:289444 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Cc: "Kim F. Storm" >> Date: Sat, 27 Jul 2024 10:57:44 -0700 >> From: Steven Allen via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> Fixing home/end (beginning of line, end of line) case seems trivial: >> don't call `line-move' in these cases (or have `line-move' short-circuit >> when `arg' is 0). However, even after reading all the comments about >> scrolling images, I'm still not sure why it's necessary to reset vscroll >> to 0. > > Because otherwise what line-move does cannot be described in sensible > terms. If vscroll is not reset, then what would be the reference for > such a "line move"? By its very definition, line-move moves N screen > lines wrt the line which was its starting point, but with vscroll > non-zero that starting point could be anywhere. I'm a bit confused because vscroll is about scrolling the window and `line-move' is about moving point (only incidentally scrolling the window if the point leaves it). Clearly `set-window-start' needs to reset `vscroll', but I'm not sure I understand why `line-move' does. Is this about detecting the correct column? > In addition, when we move to another screen line, the value of vscroll > cannot be meaningfully kept, because its meaning is tightly coupled to > the screen line where it was applied. In essence, vscroll is a trick > to allow display of a tall display element (image, text using a large > fonts, etc.) in a window whose height is too small to show all of the > display element at once. > >> After commenting this line out, I can't tell a difference, even >> when scrolling images with and without `auto-window-vscroll' and >> `try-vscroll'. > > line-move is not just for scrolling across images, it is also about > scrolling across tall text lines and other display elements. In any > case, asking for removal of that reset is a non-starter, for the > reasons explained above, so it isn't going to happen. The solution > for any Lisp program that doesn't want vscroll to be rest is not to > call line-move. Now that I do more testing, I can see how removing that line breaks `line-move' although I'm still not sure why. Would it be acceptable to restore the vertical scroll position as long as `line-move' hasn't otherwise scrolled the screen? See attached patch. >> I was hoping Kim could shed some light on this. > > I'd be thrilled to hear from Kim, but I'm as guilty of the code in > line-move as he is, so "blame" me if you want. Ah, sorry, should have gone back further in the blame history. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Restore-vertical-scroll-offset-after-line-move.patch >From 2f028e30b2e5ba3a3cd9fd2ecaeaff7c3d02b62f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 27 Jul 2024 12:54:31 -0700 Subject: [PATCH] Restore vertical-scroll offset after line-move Restore the vertical-scroll offset after moving lines unless the window was otherwise scrolled and/or altering the vertical scroll would move the point off-screen. * lisp/simple.el (line-move): restore `window-vscroll' when appropriate (Bug#72323). --- lisp/simple.el | 85 ++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index a9f8b5845d8..71ae175d198 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -7930,43 +7930,54 @@ line-move ;; doesn't have very long lines. (long-line-optimizations-p))) (line-move-partial arg noerror)) - (set-window-vscroll nil 0 t) - (if (and line-move-visual - ;; Display-based column are incompatible with goal-column. - (not goal-column) - ;; Lines aren't truncated. - (not - (and - (or truncate-lines (truncated-partial-width-window-p)) - (long-line-optimizations-p))) - ;; When the text in the window is scrolled to the left, - ;; display-based motion doesn't make sense (because each - ;; logical line occupies exactly one screen line). - (not (> (window-hscroll) 0)) - ;; Likewise when the text _was_ scrolled to the left - ;; when the current run of vertical motion commands - ;; started. - (not (and (memq last-command - `(next-line previous-line ,this-command)) - auto-hscroll-mode - (numberp temporary-goal-column) - (>= temporary-goal-column - (- (window-width) hscroll-margin))))) - (prog1 (line-move-visual arg noerror) - ;; If we moved into a tall line, set vscroll to make - ;; scrolling through tall images more smooth. - (let ((lh (line-pixel-height)) - (edges (window-inside-pixel-edges)) - (dlh (default-line-height)) - winh) - (setq winh (- (nth 3 edges) (nth 1 edges) 1)) - (if (and (< arg 0) - (< (point) (window-start)) - (> lh winh)) - (set-window-vscroll - nil - (- lh dlh) t)))) - (line-move-1 arg noerror))))) + (let ((initial-vscroll (window-vscroll nil t)) + (initial-window-start (window-start))) + (set-window-vscroll nil 0 t) + (prog1 + (if (and line-move-visual + ;; Display-based column are incompatible with goal-column. + (not goal-column) + ;; Lines aren't truncated. + (not + (and + (or truncate-lines (truncated-partial-width-window-p)) + (long-line-optimizations-p))) + ;; When the text in the window is scrolled to the left, + ;; display-based motion doesn't make sense (because each + ;; logical line occupies exactly one screen line). + (not (> (window-hscroll) 0)) + ;; Likewise when the text _was_ scrolled to the left + ;; when the current run of vertical motion commands + ;; started. + (not (and (memq last-command + `(next-line previous-line ,this-command)) + auto-hscroll-mode + (numberp temporary-goal-column) + (>= temporary-goal-column + (- (window-width) hscroll-margin))))) + (prog1 (line-move-visual arg noerror) + ;; If we moved into a tall line, set vscroll to make + ;; scrolling through tall images more smooth. + (let ((lh (line-pixel-height)) + (edges (window-inside-pixel-edges)) + (dlh (default-line-height)) + winh) + (setq winh (- (nth 3 edges) (nth 1 edges) 1)) + (if (and (< arg 0) + (< (point) (window-start)) + (> lh winh)) + (set-window-vscroll + nil + (- lh dlh) t)))) + (line-move-1 arg noerror)) + ;; Restore the vscroll position, if any. + (when (and (not (zerop initial-vscroll)) + ;; But not if scrolling would hide the point. + (< initial-vscroll (cdr (posn-x-y (posn-at-point)))) + ;; Or if line-move otherwise scrolled the window. + (= initial-window-start (window-start)) + (zerop (window-vscroll nil t))) + (set-window-vscroll nil initial-vscroll t))))))) ;; Display-based alternative to line-move-1. ;; Arg says how many lines to move. The value is t if we can move the -- 2.45.2 --=-=-=--