From: "J.P." <jp@neverwas.me>
To: 64855@debbugs.gnu.org
Cc: emacs-erc@gnu.org
Subject: bug#64855: 30.0.50; ERC 5.6: Make scrolltobottom less erratic
Date: Tue, 24 Oct 2023 19:15:55 -0700 [thread overview]
Message-ID: <87r0lja1lw.fsf__11934.8874011607$1698200225$gmane$org@neverwas.me> (raw)
In-Reply-To: <871qdy9hbz.fsf@neverwas.me> (J. P.'s message of "Fri, 13 Oct 2023 17:29:52 -0700")
[-- Attachment #1: Type: text/plain, Size: 879 bytes --]
"J.P." <jp@neverwas.me> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-5.6-Be-slightly-more-aggressive-in-erc-scrolltobotto.patch --]
[-- Type: text/x-patch, Size: 3861 bytes --]
From 3e538317bade00780bb54a31aafd58689ee9eb42 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
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
next prev parent reply other threads:[~2023-10-25 2:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-25 13:40 bug#64855: 30.0.50; ERC 5.6: Make scrolltobottom less erratic J.P.
2023-07-26 13:27 ` J.P.
2023-08-09 15:00 ` J.P.
2023-08-18 13:50 ` J.P.
2023-08-24 14:11 ` J.P.
[not found] ` <87il948r8x.fsf@neverwas.me>
2023-09-13 14:05 ` J.P.
[not found] ` <871qf2183j.fsf@neverwas.me>
2023-09-19 13:38 ` J.P.
2023-10-11 2:53 ` J.P.
[not found] ` <87o7h5euo8.fsf@neverwas.me>
2023-10-14 0:29 ` J.P.
[not found] ` <871qdy9hbz.fsf@neverwas.me>
2023-10-25 2:15 ` J.P. [this message]
[not found] ` <87r0lja1lw.fsf@neverwas.me>
2023-10-30 13:46 ` J.P.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='87r0lja1lw.fsf__11934.8874011607$1698200225$gmane$org@neverwas.me' \
--to=jp@neverwas.me \
--cc=64855@debbugs.gnu.org \
--cc=emacs-erc@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).