diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS index de27b8f07e7..d28c0670a73 100644 --- a/etc/ERC-NEWS +++ b/etc/ERC-NEWS @@ -16,6 +16,12 @@ GNU Emacs since Emacs version 22.1. ** Changes in the library API. +*** Module setup runs in query buffers on reconnect. +A module's setup would always run in channel buffers on reconnect, due +to channels being rejoined, but query buffers lacked a similar +opportunity to reinitialize their state for the new session. This is no +longer the case. + *** Local modules activate in preferred order instead of in reverse. In recent versions, ERC has enabled local modules in the reverse order of that produced by the "set" function used by 'setopt' and the Custom diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 6781c3d117d..591ca1f5fbe 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -6840,9 +6840,16 @@ See also: `erc-echo-notice-in-user-buffers', (erc-update-mode-line) (erc-set-initial-user-mode nick buffer) (erc-server-setup-periodical-ping buffer) - (when erc-unhide-query-prompt - (erc-with-all-buffers-of-server erc-server-process nil - (when (and erc--target (not (erc--target-channel-p erc--target))) + ;; Run mode hooks on all reclaimed query buffers. + (let ((buffer (current-buffer)) + (erc-join-buffer 'bury) + erc-active-buffer) + (erc-with-all-buffers-of-server erc-server-process + #'erc-query-buffer-p + (let ((target (erc-target))) + (with-current-buffer buffer + (erc--open-target target))) + (when erc-unhide-query-prompt (erc--unhide-prompt)))) (run-hook-with-args 'erc-after-connect server nick)))))