From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Tue, 17 Aug 2021 01:50:29 -0700 Subject: [PATCH 03/28] Require erc-networks in erc.el * lisp/erc/erc.el: Require erc-networks.el, which ERC can't run without these days. To sidestep the circular dependency, require it last, just after erc-goodies, and insert a `declare-function' for `erc-network' before it's used. It may be preferable to move this and the counterpart for `erc-network-name' to the top of the file in a followup commit. Note requiring this library isn't the same as auto-enabling the module because the hooks still won't be registered. (erc-log-irc-protocol, erc-hide-current-message-p, erc-handle-irc-url): Remove `fboundp' guard logic from `erc-network-name' invocations but preserve meaning by interpreting `erc-network' being unset to mean module isn't loaded or authoritative network detection has failed. (erc-format-network): Likewise here because, ATM, this function always returns "" because the function `erc-network-name' always returns non-nil, perhaps from the fallback/failure sentinel "Unknown", perhaps from the printed form of nil. * lisp/erc/erc-networks.el (erc-network): Don't autoload erc-determine-network, which only runs once per session and for which third-party code has little use. OTOH, erc-network is de facto require'd by erc.el and is cumbersome to use when guarded everywhere by fboundp. --- lisp/erc/erc-networks.el | 3 +-- lisp/erc/erc.el | 14 ++++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lisp/erc/erc-networks.el b/lisp/erc/erc-networks.el index 678c596760..6ec5bc74a8 100644 --- a/lisp/erc/erc-networks.el +++ b/lisp/erc/erc-networks.el @@ -733,7 +733,6 @@ erc-network ;; Functions: -;;;###autoload (defun erc-determine-network () "Return the name of the network or \"Unknown\" as a symbol. Use the server parameter NETWORK if provided, otherwise parse the @@ -753,7 +752,7 @@ erc-determine-network (defun erc-network () "Return the value of `erc-network' for the current server." - (erc-with-server-buffer erc-network)) + (or erc-network (erc-with-server-buffer erc-network))) (defun erc-network-name () "Return the name of the current network as a string." diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 4a9d153553..a06166b565 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1595,6 +1595,8 @@ erc-port-equal "Check whether ports A and B are equal." (= (erc-normalize-port a) (erc-normalize-port b))) +(declare-function 'erc-network "erc-networks") + (defun erc-generate-new-buffer-name (server port target) "Create a new buffer name based on the arguments." (when (numberp port) (setq port (number-to-string port))) @@ -2354,9 +2356,7 @@ erc-log-irc-protocol available at run time, starting with the network name, followed by the announced host name, and falling back to the dialed :." (when erc-debug-irc-protocol - (let ((esid (or (and (fboundp 'erc-network) - (erc-network) - (erc-network-name)) + (let ((esid (or (and (erc-network) (erc-network-name)) erc-server-announced-name (format "%s:%s" erc-session-server erc-session-port))) (ts (when erc-debug-irc-protocol-time-format @@ -2758,7 +2758,7 @@ erc-hide-current-message-p (let* ((command (erc-response.command parsed)) (sender (car (erc-parse-user (erc-response.sender parsed)))) (channel (car (erc-response.command-args parsed))) - (network (or (and (fboundp 'erc-network-name) (erc-network-name)) + (network (or (and (erc-network) (erc-network-name)) (erc-shorten-server-name (or erc-server-announced-name erc-session-server)))) @@ -6492,10 +6492,7 @@ erc-format-target-and/or-server (defun erc-format-network () "Return the name of the network we are currently on." - (let ((network (and (fboundp 'erc-network-name) (erc-network-name)))) - (if (and network (symbolp network)) - (symbol-name network) - ""))) + (erc-network-name)) (defun erc-format-target-and/or-network () "Return the network or the current target and network combined. @@ -7046,5 +7043,6 @@ erc-handle-irc-url ;; IMPORTANT: This require must appear _after_ the above (provide 'erc) to ;; avoid a recursive require error when byte-compiling the entire package. (require 'erc-goodies) +(require 'erc-networks) ;;; erc.el ends here -- 2.31.1