From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#64855: 30.0.50; ERC 5.6: Make scrolltobottom less erratic Date: Tue, 24 Oct 2023 19:15:55 -0700 Message-ID: <87r0lja1lw.fsf__11934.8874011607$1698200225$gmane$org@neverwas.me> References: <87h6psyurb.fsf@neverwas.me> <87o7h5euo8.fsf@neverwas.me> <871qdy9hbz.fsf@neverwas.me> 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="11260"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org To: 64855@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 25 04:16:57 2023 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 1qvTS5-0002i6-9M for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Oct 2023 04:16:57 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvTRi-0003RR-7M; Tue, 24 Oct 2023 22:16:34 -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 1qvTRg-0003R7-AV for bug-gnu-emacs@gnu.org; Tue, 24 Oct 2023 22:16:32 -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 1qvTRf-0002K0-W5 for bug-gnu-emacs@gnu.org; Tue, 24 Oct 2023 22:16:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qvTS9-0007M7-L7 for bug-gnu-emacs@gnu.org; Tue, 24 Oct 2023 22:17:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Oct 2023 02:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64855 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64855-submit@debbugs.gnu.org id=B64855.169820019828240 (code B ref 64855); Wed, 25 Oct 2023 02:17:01 +0000 Original-Received: (at 64855) by debbugs.gnu.org; 25 Oct 2023 02:16:38 +0000 Original-Received: from localhost ([127.0.0.1]:56977 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvTRl-0007LP-Nm for submit@debbugs.gnu.org; Tue, 24 Oct 2023 22:16:38 -0400 Original-Received: from mail-108-mta225.mxroute.com ([136.175.108.225]:45483) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvTRg-0007L5-Fb for 64855@debbugs.gnu.org; Tue, 24 Oct 2023 22:16:36 -0400 Original-Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta225.mxroute.com (ZoneMTA) with ESMTPSA id 18b649e05b20008912.001 for <64855@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 25 Oct 2023 02:15:59 +0000 X-Zone-Loop: 2e88826f8941f3e7e217a21df330e4a3c9d7b8b789ea X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=fVolk0yPnD4juLWsYnsTQWmVDjGFJ6nyXClSvqMftNM=; b=RsjX7TCpPK36uBWSiSU6KewrnS I93d5MSG4xcx189YHMx9u5TOUINIlLEsm6vLinWdMZxaL/1NqKnmiSYkRiSGFku1Glto43beZENpi GxONe+ElqpM7IU0EwvpL2ouut92UpYvonT1i4gjA5M4Ihp7LQqiTJmI/xB3NRNisjxdJBbyyOMLxH wTzvW0Tz1AmAKgy3M2P+Q+S2JH0DobMzAy1obCgyqvkAQUtJ2r3iUL/24dVxOuJ/HoQAT3+phpL5s 8fq1LafvcmQXcK1OndFXPa2SrwzfM/LDYYOAnQBQNAfMJC4WE4O3reyHYh5rQgWQbARJ74Q+549JE Asfdc6SQ==; In-Reply-To: <871qdy9hbz.fsf@neverwas.me> (J. P.'s message of "Fri, 13 Oct 2023 17:29:52 -0700") X-Authenticated-Id: masked@neverwas.me 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:273135 Archived-At: --=-=-= Content-Type: text/plain "J.P." writes: > I've added these changes as > > https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=328a9856 > > This bug has already been closed. Thanks. But wait, there's more! (There's always more.) It seems I went a little overboard in reigning in the frequency of scroll attempts. This has been walked back slightly in the attached changes. There's also a subtle quirk that's come to light involving `point-max' and (recenter -1) where Emacs calculates point as having drifted off screen. We could try tackling this with something kludgey, like decrementing point temporarily during `recenter' attempts. But that fails if the current input ends in a newline. I've instead decided to address this by taking a page from other Emacs libraries and setting `scroll-step' locally to 1 if a user hasn't customized `scroll-conservatively'. See attached. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-5.6-Be-slightly-more-aggressive-in-erc-scrolltobotto.patch >From 3e538317bade00780bb54a31aafd58689ee9eb42 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Tue, 24 Oct 2023 18:18:50 -0700 Subject: [PATCH] [5.6] Be slightly more aggressive in erc-scrolltobottom-all * lisp/erc/erc-goodies.el (erc--scrolltobottom-on-post-command): Redo obsolete doc string. (erc--scrolltobottom-at-prompt-minibuffer-active, erc--scrolltobottom-on-win-conf-change): Rename former to latter to better reflect actual role. Remove conditional guard so this always runs. (erc--scrolltobottom-setup): Set `scroll-step' locally when a user hasn't customized `scroll-conservatively'. Update hook member names. (Bug#64855) --- lisp/erc/erc-goodies.el | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 9d70c644429..e854d063cdd 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -119,28 +119,20 @@ erc--scrolltobottom-post-ignore-commands "Commands to skip instead of force-scroll on `post-command-hook'.") (defun erc--scrolltobottom-on-post-command () - "Restore window start or scroll to prompt and recenter. -When `erc--scrolltobottom-window-info' is non-nil and its first -item is associated with the selected window, restore start of -window so long as prompt hasn't moved. Expect buffer to be -unnarrowed." + "Scroll selected window unless `this-command' is exempted." (when (eq (selected-window) (get-buffer-window)) (unless (memq this-command erc--scrolltobottom-post-ignore-commands) - (erc--scrolltobottom-confirm)) - (setq erc--scrolltobottom-window-info nil))) + (setq erc--scrolltobottom-window-info nil) + (erc--scrolltobottom-confirm)))) ;; It may be desirable to also restore the relative line position of ;; window point after changing dimensions. Perhaps stashing the ;; previous ratio of window line to body height and later recentering ;; proportionally would achieve this. -(defun erc--scrolltobottom-at-prompt-minibuffer-active () +(defun erc--scrolltobottom-on-win-conf-change () "Scroll window to bottom when at prompt and using the minibuffer." - ;; This is redundant or ineffective in the selected window if at - ;; prompt or if only one window exists. - (unless (or (input-pending-p) - (and (minibuffer-window-active-p (minibuffer-window)) - (eq (old-selected-window) (minibuffer-window)))) - (erc--scrolltobottom-confirm))) + (setq erc--scrolltobottom-window-info nil) + (erc--scrolltobottom-confirm)) (defun erc--scrolltobottom-all (&rest _) "Maybe put prompt on last line in all windows displaying current buffer. @@ -176,16 +168,18 @@ erc--scrolltobottom-setup (if erc-scrolltobottom-all (progn (setq-local read-minibuffer-restore-windows nil) + (when (zerop scroll-conservatively) + (setq-local scroll-step 1)) (unless (eq erc-scrolltobottom-all 'relaxed) (add-hook 'window-configuration-change-hook - #'erc--scrolltobottom-at-prompt-minibuffer-active 50 t) + #'erc--scrolltobottom-on-win-conf-change 50 t) (add-hook 'post-command-hook #'erc--scrolltobottom-on-post-command 50 t))) (add-hook 'post-command-hook #'erc-scroll-to-bottom nil t)) (remove-hook 'post-command-hook #'erc-scroll-to-bottom t) (remove-hook 'post-command-hook #'erc--scrolltobottom-on-post-command t) (remove-hook 'window-configuration-change-hook - #'erc--scrolltobottom-at-prompt-minibuffer-active t) + #'erc--scrolltobottom-on-win-conf-change t) (kill-local-variable 'read-minibuffer-restore-windows) (kill-local-variable 'erc--scrolltobottom-window-info))) -- 2.41.0 --=-=-=--