>From 78e5fa32620b386b283f16383f16c713e628a0ff Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Fri, 18 Aug 2023 06:36:44 -0700 Subject: [PATCH 0/1] *** NOT A PATCH *** *** BLURB HERE *** F. Jason Park (1): [5.6] Consider all windows in erc-scrolltobottom-mode lisp/erc/erc-goodies.el | 222 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 208 insertions(+), 14 deletions(-) Interdiff: diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 129e17fb5ec..891641f77f7 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -100,15 +100,15 @@ erc--scrolltobottom-window-info `window-point', inclusive.") (defvar erc--scrolltobottom-post-force-commands - '(electric-newline-and-maybe-indent) + '(electric-newline-and-maybe-indent default-indent-new-line) "Commands that force a scroll after execution at prompt.") -(defvar erc--scrolltobottom-relaxed-skip-commands '(recenter-top-bottom)) +(defvar erc--scrolltobottom-relaxed-skip-commands + '(recenter-top-bottom scroll-down-command)) (defun erc--scrolltobottom-on-pre-command () - (cl-assert (not erc-scrolltobottom-relaxed)) ; delete me - (cl-assert (eq (selected-window) (get-buffer-window))) ; delete me - (when (> (point) erc-input-marker) + (when (and (eq (selected-window) (get-buffer-window)) + (>= (point) erc-input-marker)) (setq erc--scrolltobottom-window-info (list (list (selected-window) (window-start) @@ -120,17 +120,17 @@ erc--scrolltobottom-on-post-command item is associated with the selected window, restore start of window so long as prompt hasn't moved. Expect buffer to be unnarrowed." - (cl-assert (not erc-scrolltobottom-relaxed)) ; delete me - (cl-assert (eq (selected-window) (get-buffer-window))) ; delete me - (if-let (((not (input-pending-p))) - (erc--scrolltobottom-window-info) - (found (car erc--scrolltobottom-window-info)) - ((eq (car found) (selected-window))) - ((not (memq this-command erc--scrolltobottom-post-force-commands))) - ((= (nth 2 found) (count-screen-lines (window-start) (point))))) - (set-window-start (selected-window) (nth 1 found)) - (erc--scrolltobottom-confirm)) - (setq erc--scrolltobottom-window-info nil)) + (when (eq (selected-window) (get-buffer-window)) + (if-let (((not (input-pending-p))) + (erc--scrolltobottom-window-info) + (found (car erc--scrolltobottom-window-info)) + ((eq (car found) (selected-window))) + ((not (memq this-command + erc--scrolltobottom-post-force-commands))) + ((= (nth 2 found) (count-screen-lines (window-start) (point))))) + (set-window-start (selected-window) (nth 1 found)) + (erc--scrolltobottom-confirm)) + (setq erc--scrolltobottom-window-info nil))) (defun erc--scrolltobottom-on-pre-command-relaxed () "Maybe scroll to bottom when away from prompt in an unnarrowed buffer. @@ -139,28 +139,26 @@ erc--scrolltobottom-on-pre-command-relaxed `self-insert-command' (assuming `move-to-prompt' is active). When at prompt and current command is not `recenter-top-bottom', stash `erc--scrolltobottom-window-info' for the selected window." - (cl-assert erc-scrolltobottom-relaxed) ; delete me - (cl-assert (eq (selected-window) (get-buffer-window))) ; delete me - (when (and (not (input-pending-p)) - (< (point) erc-input-marker) - (memq this-command erc--scrolltobottom-relaxed-commands) - (< (window-end nil t) erc-input-marker)) - (save-excursion - (goto-char (point-max)) - (recenter (or erc-input-line-position -1)))) - (when (and (> (point) erc-input-marker) - (not (memq this-command - erc--scrolltobottom-relaxed-skip-commands))) - (setq erc--scrolltobottom-window-info - (list (list (selected-window) - (window-start) - (count-screen-lines (window-start) (point-max))))))) + (when (eq (selected-window) (get-buffer-window)) + (when (and (not (input-pending-p)) + (< (point) erc-input-marker) + (memq this-command erc--scrolltobottom-relaxed-commands) + (< (window-end nil t) erc-input-marker)) + (save-excursion + (goto-char (point-max)) + (recenter (or erc-input-line-position -1)))) + (when (and (>= (point) erc-input-marker) + (not (memq this-command + erc--scrolltobottom-relaxed-skip-commands))) + (setq erc--scrolltobottom-window-info + (list (list (selected-window) + (window-start) + (count-screen-lines (window-start) (point-max)))))))) (defun erc--scrolltobottom-on-post-command-relaxed () "Set window start or scroll when data was captured on pre-command." - (cl-assert erc-scrolltobottom-relaxed) ; delete me - (cl-assert (eq (selected-window) (get-buffer-window))) ; delete me - (when-let ((erc--scrolltobottom-window-info) + (when-let (((eq (selected-window) (get-buffer-window))) + (erc--scrolltobottom-window-info) (found (car erc--scrolltobottom-window-info)) ((eq (car found) (selected-window)))) (if (and (not (memq this-command erc--scrolltobottom-post-force-commands)) @@ -217,13 +215,13 @@ erc-add-scroll-to-bottom (cl-pushnew 'self-insert-command erc--scrolltobottom-relaxed-commands)) (add-hook 'post-command-hook - #'erc--scrolltobottom-on-post-command-relaxed -90 t) + #'erc--scrolltobottom-on-post-command-relaxed 60 t) (add-hook 'pre-command-hook ; preempt `move-to-prompt' - #'erc--scrolltobottom-on-pre-command-relaxed -90 t)) + #'erc--scrolltobottom-on-pre-command-relaxed 60 t)) (add-hook 'pre-command-hook - #'erc--scrolltobottom-on-pre-command nil t) + #'erc--scrolltobottom-on-pre-command 60 t) (add-hook 'post-command-hook - #'erc--scrolltobottom-on-post-command nil t))) + #'erc--scrolltobottom-on-post-command 60 t))) (remove-hook 'window-configuration-change-hook #'erc--scrolltobottom-away-from-prompt t) (remove-hook 'pre-command-hook @@ -246,7 +244,7 @@ erc--scrolltobottom-on-pre-insert (and-let* ((erc-scrolltobottom-relaxed) (c (count-screen-lines (window-start w) - (window-point w) nil w))) + (point-max) nil w))) (if (= ?\n (char-before (point-max))) (1+ c) c)))) (get-buffer-window-list nil nil 'visible)))) @@ -328,7 +326,7 @@ erc-move-to-prompt (defun erc-move-to-prompt-setup () "Initialize the move-to-prompt module." - (add-hook 'pre-command-hook #'erc-move-to-prompt nil t)) + (add-hook 'pre-command-hook #'erc-move-to-prompt 70 t)) ;;; Keep place in unvisited channels ;;;###autoload(autoload 'erc-keep-place-mode "erc-goodies" nil t) -- 2.41.0