summaryrefslogtreecommitdiff
path: root/lisp/erc/erc-goodies.el
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2023-05-07 19:43:57 -0700
committerF. Jason Park <jp@neverwas.me>2023-05-13 07:05:22 -0700
commit867b104010760c4b7cd700078884cc774a01860a (patch)
tree60e980b56bfb33169d792422ebf985c89bd8680e /lisp/erc/erc-goodies.el
parent75a412d78b6f4b4b68a7c649047cd28320110c09 (diff)
downloademacs-867b104010760c4b7cd700078884cc774a01860a.tar.gz
Make some module toggles more resilient in ERC
* lisp/erc/erc-goodies.el (erc-scrolltobottom-mode, erc-scrolltobottom-enable, erc-move-to-prompt-mode, erc-move-to-prompt-enable): Guard setup procedure behind `erc--updating-modules-p'. * lisp/erc/erc-imenu.el (erc-imenu-mode, erc-imenu-enable, erc-imenu-disable): Don't run setup when `erc--updating-modules-p' is non-nil. Also, don't restrict teardown to buffers of the same process. * lisp/erc/erc-match.el (erc-match-mode, erc-match-enable): Run major-mode hook member immediately outside of `erc-update-modules' in `erc-open'. * lisp/erc/erc-spelling.el (erc-spelling-mode, erc-spelling-enable): Only conditionally run setup immediately. * lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-enable, erc-stamp-disable): Run setup hook immediately. Don't forget to kill local vars in all ERC buffers during teardown. * lisp/erc/erc.el (erc--updating-modules-p): New variable that global modules can use to provide their `erc-mode-hook'-deferred code on demand while shielding it from running during early ERC buffer initialization. (erc-open): Make `erc--updating-modules-p' non-nil while activating global modules. (Bug#60936)
Diffstat (limited to 'lisp/erc/erc-goodies.el')
-rw-r--r--lisp/erc/erc-goodies.el10
1 files changed, 4 insertions, 6 deletions
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 4558ff7c076..01eae4b63c5 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -53,9 +53,8 @@ argument to `recenter'."
"This mode causes the prompt to stay at the end of the window."
((add-hook 'erc-mode-hook #'erc-add-scroll-to-bottom)
(add-hook 'erc-insert-done-hook #'erc-possibly-scroll-to-bottom)
- (dolist (buffer (erc-buffer-list))
- (with-current-buffer buffer
- (erc-add-scroll-to-bottom))))
+ (unless erc--updating-modules-p
+ (erc-buffer-filter #'erc-add-scroll-to-bottom)))
((remove-hook 'erc-mode-hook #'erc-add-scroll-to-bottom)
(remove-hook 'erc-insert-done-hook #'erc-possibly-scroll-to-bottom)
(dolist (buffer (erc-buffer-list))
@@ -120,9 +119,8 @@ Put this function on `erc-insert-post-hook' and/or `erc-send-post-hook'."
(define-erc-module move-to-prompt nil
"This mode causes the point to be moved to the prompt when typing text."
((add-hook 'erc-mode-hook #'erc-move-to-prompt-setup)
- (dolist (buffer (erc-buffer-list))
- (with-current-buffer buffer
- (erc-move-to-prompt-setup))))
+ (unless erc--updating-modules-p
+ (erc-buffer-filter #'erc-move-to-prompt-setup)))
((remove-hook 'erc-mode-hook #'erc-move-to-prompt-setup)
(dolist (buffer (erc-buffer-list))
(with-current-buffer buffer