aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2025-09-03 17:48:21 -0700
committerF. Jason Park2025-09-04 17:12:25 -0700
commitfca0dbe0ab2930e39aaec304df3e6bb7cad17995 (patch)
treecae959434e5492a237b8b7d61fead28d4d5f2db2
parentb3abbab63254fd18e1c7bad56d3401b49dd8604c (diff)
downloademacs-fca0dbe0ab2930e39aaec304df3e6bb7cad17995.tar.gz
emacs-fca0dbe0ab2930e39aaec304df3e6bb7cad17995.zip
Make function erc-scrolltobottom-mode idempotent
* lisp/erc/erc-goodies.el (erc-scrolltobottom-mode) (erc-scrolltobottom-enable): Always remove hook functions whose membership hinges on the value of `erc-scrolltobottom-all'. In ERC 5.6, an init file's `setopt' form containing an `erc-modules' assignment before an `erc-scrolltobottom-all' one would result in conflicting sets of hook members come `erc-open'. Having such option-dependent branching in module setup, while difficult to maintain, is a long held ERC practice, as seen in functions like `erc-nickserv-identify-mode'. Making all new modules "local" may be the most manageable solution because existing global modules can't be made to require prior deactivation.
-rw-r--r--lisp/erc/erc-goodies.el5
1 files changed, 5 insertions, 0 deletions
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 24a3205e0cd..2a787f3e014 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -87,10 +87,15 @@ be experimental. It currently only works with Emacs 28+."
87 (unless erc--updating-modules-p (erc-buffer-do #'erc--scrolltobottom-setup)) 87 (unless erc--updating-modules-p (erc-buffer-do #'erc--scrolltobottom-setup))
88 (if erc-scrolltobottom-all 88 (if erc-scrolltobottom-all
89 (progn 89 (progn
90 (remove-hook 'erc-insert-done-hook #'erc-possibly-scroll-to-bottom)
90 (add-hook 'erc-insert-pre-hook #'erc--scrolltobottom-on-pre-insert 25) 91 (add-hook 'erc-insert-pre-hook #'erc--scrolltobottom-on-pre-insert 25)
91 (add-hook 'erc-pre-send-functions #'erc--scrolltobottom-on-pre-insert) 92 (add-hook 'erc-pre-send-functions #'erc--scrolltobottom-on-pre-insert)
92 (add-hook 'erc-insert-done-hook #'erc--scrolltobottom-all) 93 (add-hook 'erc-insert-done-hook #'erc--scrolltobottom-all)
93 (add-hook 'erc-send-completed-hook #'erc--scrolltobottom-all)) 94 (add-hook 'erc-send-completed-hook #'erc--scrolltobottom-all))
95 (remove-hook 'erc-insert-pre-hook #'erc--scrolltobottom-on-pre-insert)
96 (remove-hook 'erc-pre-send-functions #'erc--scrolltobottom-on-pre-insert)
97 (remove-hook 'erc-insert-done-hook #'erc--scrolltobottom-all)
98 (remove-hook 'erc-send-completed-hook #'erc--scrolltobottom-all)
94 (add-hook 'erc-insert-done-hook #'erc-possibly-scroll-to-bottom))) 99 (add-hook 'erc-insert-done-hook #'erc-possibly-scroll-to-bottom)))
95 ((remove-hook 'erc-mode-hook #'erc--scrolltobottom-setup) 100 ((remove-hook 'erc-mode-hook #'erc--scrolltobottom-setup)
96 (erc-buffer-do #'erc--scrolltobottom-setup) 101 (erc-buffer-do #'erc--scrolltobottom-setup)