From 2ddc480f4417775d6bf8ebcfc27b8cd7fa761a7d Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Sun, 25 Dec 2022 21:36:53 -0800 Subject: Warn of absent networks module in ERC * doc/misc/erc.texi: Add linkable note in Modules chapter about some modules being required. Also tweak markup in auth-source section. * etc/ERC-NEWS: Mention the special role of `networks'. * lisp/erc/erc-backend.el (erc--server-post-connect-hook): Add internal hook for core modules to perform post-network-process, pre-protocol config validation even when they haven't been loaded. (erc--register-connection): Run `erc--server-post-connect-hook'. * lisp/erc/erc-networks.el (erc-networks--bouncer-targets, erc-networks-on-MOTD-end): Fix comments and doc strings. Also change former from constant to internal variable in case adjustment needed between releases. (erc-networks--warn-on-connect): New function to warn about the `networks' module being absent from `erc-modules'. This could probably run at any time up to and including when the logical IRC connection is established, but doing so at the process/protocol boundary seems ideal. * lisp/erc/erc-sasl.el (erc--register-connection): Defer to base method instead of calling `erc-login' explicitly. * lisp/erc/erc.el (erc-generate-new-buffer-name): Don't reconcile buffer names when networks module not in play. (erc-format-target-and/or-network): Don't assume networks module loaded. * test/lisp/erc/erc-scenarios-base-unstable.el: (erc-scenarios-networks-no-module): New test. * test/lisp/erc/resources/networks/no-module/basic.eld: New test data file. (Bug#60331.) --- lisp/erc/erc-backend.el | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lisp/erc/erc-backend.el') diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 43c5faad638..6820bf0d1a3 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -320,6 +320,15 @@ session when reconnecting. Once `erc-reuse-buffers' is retired and fully removed, modules can switch to leveraging the `permanent-local' property instead.") +(defvar erc--server-post-connect-hook '(erc-networks--warn-on-connect) + "Functions to run when a network connection is successfully opened. +Though internal, this complements `erc-connect-pre-hook' in that +it bookends the process rather than the logical connection, which +is the domain of `erc-before-connect' and `erc-after-connect'. +Note that unlike `erc-connect-pre-hook', this only runs in server +buffers, and it does so immediately before the first protocol +exchange.") + (defvar-local erc-server-timed-out nil "Non-nil if the IRC server failed to respond to a ping.") @@ -646,6 +655,7 @@ The current buffer is given by BUFFER." (cl-defmethod erc--register-connection () "Perform opening IRC protocol exchange with server." + (run-hooks 'erc--server-post-connect-hook) (erc-login)) (defvar erc--server-connect-dumb-ipv6-regexp -- cgit v1.2.3