Run module setup in ERC query buffers on reconnect

* etc/ERC-NEWS: Mention change.
* lisp/erc/erc.el (erc-connection-established): Apply `erc--open-target'
to all existing query buffers after they've been reassociated by
the erc-networks logic.
This commit is contained in:
F. Jason Park 2024-05-01 07:21:01 -07:00
parent 606c0b22e4
commit ec7a5f85c9
2 changed files with 16 additions and 3 deletions

View file

@ -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

View file

@ -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)
;; 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-with-all-buffers-of-server erc-server-process nil
(when (and erc--target (not (erc--target-channel-p erc--target)))
(erc--unhide-prompt))))
(run-hook-with-args 'erc-after-connect server nick)))))