From 06fb8b76208ad380d7d1e592394d3173249f31df Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 20 Sep 2023 21:40:36 -0700 Subject: [PATCH] Exempt text-scale-mode from erc-scrolltobottom-all * lisp/erc/erc-goodies.el (erc--scrolltobottom-post-ignore-commands): New variable, a list of commands that should not trigger a re-scroll. (erc--scrolltobottom-on-post-command): Don't `recenter' when the current command appears in `erc--scrolltobottom-post-ignore-commands'. This fixes a bug that prevented managed recentering when disabling `text-scale-mode'. Thanks to Corwin Brust for reporting this. Note that this doesn't address any fill-related alignment issues involving `text-scale-mode'. Nor does it address likely problems involving the erroneous restoration of point after the insertion of invisible lines. (erc-keep-place-enable, erc-keep-place-mode): Adjust hook depth to fall within reserved interval. (erc-keep-place-indicator-enable, erc-keep-place-indicator-mode, erc--keep-place-indicator-on-global-module): Lower hook depth to fall within reserved interval. Note that this hook has a buffer-local value, so all members run after their global counterparts. (Bug#66073) --- lisp/erc/erc-goodies.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 6eb015fdd64..b77176d8ac7 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -128,6 +128,11 @@ may be nil, is the number of lines between `window-start' and That is, ERC recalculates the window's start instead of blindly restoring it.") +;; Unfortunately, this doesn't work when `erc-scrolltobottom-relaxed' +;; is enabled (scaling up still moves the prompt). +(defvar erc--scrolltobottom-post-ignore-commands '(text-scale-adjust) + "Commands to skip instead of force-scroll on `post-command-hook'.") + (defvar erc--scrolltobottom-relaxed-skip-commands '(recenter-top-bottom scroll-down-command) "Commands exempt from triggering a stash and restore of `window-start'. @@ -158,7 +163,8 @@ unnarrowed." ((= (nth 2 found) (count-screen-lines (window-start) (point-max))))) (set-window-start (selected-window) (nth 1 found)) - (erc--scrolltobottom-confirm)) + (unless (memq this-command erc--scrolltobottom-post-ignore-commands) + (erc--scrolltobottom-confirm))) (setq erc--scrolltobottom-window-info nil))) (defun erc--scrolltobottom-on-pre-command-relaxed () @@ -372,7 +378,7 @@ Put this function on `erc-insert-post-hook' and/or `erc-send-post-hook'." ;;;###autoload(autoload 'erc-keep-place-mode "erc-goodies" nil t) (define-erc-module keep-place nil "Leave point above un-viewed text in other channels." - ((add-hook 'erc-insert-pre-hook #'erc-keep-place 85)) + ((add-hook 'erc-insert-pre-hook #'erc-keep-place 65)) ((remove-hook 'erc-insert-pre-hook #'erc-keep-place))) (defcustom erc-keep-place-indicator-style t @@ -467,7 +473,7 @@ and `keep-place-indicator' in different buffers." ((memq 'keep-place erc-modules) (erc-keep-place-mode +1)) ;; Enable a local version of `keep-place-mode'. - (t (add-hook 'erc-insert-pre-hook #'erc-keep-place 85 t))) + (t (add-hook 'erc-insert-pre-hook #'erc-keep-place 65 t))) (if (pcase erc-keep-place-indicator-buffer-type ('target erc--target) ('server (not erc--target)) @@ -490,7 +496,7 @@ That is, ensure the local module can survive a user toggling the global one." (if erc-keep-place-mode (remove-hook 'erc-insert-pre-hook #'erc-keep-place t) - (add-hook 'erc-insert-pre-hook #'erc-keep-place 85 t))) + (add-hook 'erc-insert-pre-hook #'erc-keep-place 65 t))) (defun erc-keep-place-move (pos) "Move keep-place indicator to current line or POS.