diff options
| author | F. Jason Park | 2022-12-25 21:36:53 -0800 |
|---|---|---|
| committer | F. Jason Park | 2022-12-28 06:51:38 -0800 |
| commit | 2ddc480f4417775d6bf8ebcfc27b8cd7fa761a7d (patch) | |
| tree | c37c55716af7350cd74f3cac577dc9ccd96be8d4 /lisp/erc | |
| parent | 19d00fab9aaf28dae6af5786f6e22b8558b10eea (diff) | |
| download | emacs-2ddc480f4417775d6bf8ebcfc27b8cd7fa761a7d.tar.gz emacs-2ddc480f4417775d6bf8ebcfc27b8cd7fa761a7d.zip | |
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.)
Diffstat (limited to 'lisp/erc')
| -rw-r--r-- | lisp/erc/erc-backend.el | 10 | ||||
| -rw-r--r-- | lisp/erc/erc-networks.el | 26 | ||||
| -rw-r--r-- | lisp/erc/erc-sasl.el | 2 | ||||
| -rw-r--r-- | lisp/erc/erc.el | 6 |
4 files changed, 35 insertions, 9 deletions
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 | |||
| 320 | and fully removed, modules can switch to leveraging the | 320 | and fully removed, modules can switch to leveraging the |
| 321 | `permanent-local' property instead.") | 321 | `permanent-local' property instead.") |
| 322 | 322 | ||
| 323 | (defvar erc--server-post-connect-hook '(erc-networks--warn-on-connect) | ||
| 324 | "Functions to run when a network connection is successfully opened. | ||
| 325 | Though internal, this complements `erc-connect-pre-hook' in that | ||
| 326 | it bookends the process rather than the logical connection, which | ||
| 327 | is the domain of `erc-before-connect' and `erc-after-connect'. | ||
| 328 | Note that unlike `erc-connect-pre-hook', this only runs in server | ||
| 329 | buffers, and it does so immediately before the first protocol | ||
| 330 | exchange.") | ||
| 331 | |||
| 323 | (defvar-local erc-server-timed-out nil | 332 | (defvar-local erc-server-timed-out nil |
| 324 | "Non-nil if the IRC server failed to respond to a ping.") | 333 | "Non-nil if the IRC server failed to respond to a ping.") |
| 325 | 334 | ||
| @@ -646,6 +655,7 @@ The current buffer is given by BUFFER." | |||
| 646 | 655 | ||
| 647 | (cl-defmethod erc--register-connection () | 656 | (cl-defmethod erc--register-connection () |
| 648 | "Perform opening IRC protocol exchange with server." | 657 | "Perform opening IRC protocol exchange with server." |
| 658 | (run-hooks 'erc--server-post-connect-hook) | ||
| 649 | (erc-login)) | 659 | (erc-login)) |
| 650 | 660 | ||
| 651 | (defvar erc--server-connect-dumb-ipv6-regexp | 661 | (defvar erc--server-connect-dumb-ipv6-regexp |
diff --git a/lisp/erc/erc-networks.el b/lisp/erc/erc-networks.el index 2e2d0930118..f05a98be16d 100644 --- a/lisp/erc/erc-networks.el +++ b/lisp/erc/erc-networks.el | |||
| @@ -1472,14 +1472,16 @@ to be a false alarm. If `erc-reuse-buffers' is nil, let | |||
| 1472 | (t (rename-buffer (generate-new-buffer-name name))))) | 1472 | (t (rename-buffer (generate-new-buffer-name name))))) |
| 1473 | nil) | 1473 | nil) |
| 1474 | 1474 | ||
| 1475 | ;; Soju v0.4.0 only sends ISUPPORT on upstream reconnect, so this | 1475 | ;; Soju v0.4.0 sends ISUPPORT and nothing else on upstream reconnect, |
| 1476 | ;; doesn't apply. ZNC 1.8.2, however, still sends the entire burst. | 1476 | ;; so this actually doesn't apply. ZNC 1.8.2, however, still sends |
| 1477 | (defconst erc-networks--bouncer-targets '(*status bouncerserv) | 1477 | ;; the entire burst. |
| 1478 | "Case-mapped symbols matching known bouncer service-bot targets.") | 1478 | (defvar erc-networks--bouncer-targets '(*status bouncerserv) |
| 1479 | "Symbols matching proxy-bot targets.") | ||
| 1479 | 1480 | ||
| 1480 | (defun erc-networks-on-MOTD-end (proc parsed) | 1481 | (defun erc-networks-on-MOTD-end (proc parsed) |
| 1481 | "Call on-connect functions with server PROC and PARSED message. | 1482 | "Call on-connect functions with server PROC and PARSED message." |
| 1482 | This must run before `erc-server-connected' is set." | 1483 | ;; This should normally run before `erc-server-connected' is set. |
| 1484 | ;; However, bouncers and other proxies may interfere with that. | ||
| 1483 | (when erc-server-connected | 1485 | (when erc-server-connected |
| 1484 | (unless (erc-buffer-filter (lambda () | 1486 | (unless (erc-buffer-filter (lambda () |
| 1485 | (and erc--target | 1487 | (and erc--target |
| @@ -1502,6 +1504,18 @@ This must run before `erc-server-connected' is set." | |||
| 1502 | ((remove-hook 'erc-server-376-functions #'erc-networks-on-MOTD-end) | 1504 | ((remove-hook 'erc-server-376-functions #'erc-networks-on-MOTD-end) |
| 1503 | (remove-hook 'erc-server-422-functions #'erc-networks-on-MOTD-end))) | 1505 | (remove-hook 'erc-server-422-functions #'erc-networks-on-MOTD-end))) |
| 1504 | 1506 | ||
| 1507 | (defun erc-networks--warn-on-connect () | ||
| 1508 | "Emit warning when the `networks' module hasn't been loaded. | ||
| 1509 | Ideally, do so upon opening the network process." | ||
| 1510 | (unless (or erc--target erc-networks-mode) | ||
| 1511 | (require 'info nil t) | ||
| 1512 | (let ((m (concat "Required module `networks' not loaded. If this " | ||
| 1513 | " was unexpected, please add it to `erc-modules'."))) | ||
| 1514 | ;; Assume the server buffer has been marked as active. | ||
| 1515 | (erc-display-error-notice | ||
| 1516 | nil (concat m " See Info:\"(erc) Required Modules\" for more.")) | ||
| 1517 | (lwarn 'erc :warning m)))) | ||
| 1518 | |||
| 1505 | (defun erc-ports-list (ports) | 1519 | (defun erc-ports-list (ports) |
| 1506 | "Return a list of PORTS. | 1520 | "Return a list of PORTS. |
| 1507 | 1521 | ||
diff --git a/lisp/erc/erc-sasl.el b/lisp/erc/erc-sasl.el index 78d02a46381..23110d74b5e 100644 --- a/lisp/erc/erc-sasl.el +++ b/lisp/erc/erc-sasl.el | |||
| @@ -435,7 +435,7 @@ Otherwise, expect it to disappear in subsequent versions.") | |||
| 435 | (if (eq :user (alist-get 'user erc-sasl--options)) | 435 | (if (eq :user (alist-get 'user erc-sasl--options)) |
| 436 | (erc-current-nick) | 436 | (erc-current-nick) |
| 437 | erc-session-username))) | 437 | erc-session-username))) |
| 438 | (erc-login)) | 438 | (cl-call-next-method)) |
| 439 | (when erc-sasl--send-cap-ls | 439 | (when erc-sasl--send-cap-ls |
| 440 | (erc-server-send "CAP REQ :sasl")) | 440 | (erc-server-send "CAP REQ :sasl")) |
| 441 | (erc-server-send (format "AUTHENTICATE %s" m))) | 441 | (erc-server-send (format "AUTHENTICATE %s" m))) |
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 6a5e0018964..16a0aba77b1 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el | |||
| @@ -1607,7 +1607,8 @@ same manner." | |||
| 1607 | (when target ; compat | 1607 | (when target ; compat |
| 1608 | (setq tgt-info (erc--target-from-string target))) | 1608 | (setq tgt-info (erc--target-from-string target))) |
| 1609 | (if tgt-info | 1609 | (if tgt-info |
| 1610 | (let* ((esid (erc-networks--id-symbol erc-networks--id)) | 1610 | (let* ((esid (and erc-networks--id |
| 1611 | (erc-networks--id-symbol erc-networks--id))) | ||
| 1611 | (name (if esid | 1612 | (name (if esid |
| 1612 | (erc-networks--reconcile-buffer-names tgt-info | 1613 | (erc-networks--reconcile-buffer-names tgt-info |
| 1613 | erc-networks--id) | 1614 | erc-networks--id) |
| @@ -6760,7 +6761,8 @@ This should be a string with substitution variables recognized by | |||
| 6760 | If the name of the network is not available, then use the | 6761 | If the name of the network is not available, then use the |
| 6761 | shortened server name instead." | 6762 | shortened server name instead." |
| 6762 | (if-let ((erc--target) | 6763 | (if-let ((erc--target) |
| 6763 | (name (if-let ((esid (erc-networks--id-symbol erc-networks--id))) | 6764 | (name (if-let ((erc-networks--id) |
| 6765 | (esid (erc-networks--id-symbol erc-networks--id))) | ||
| 6764 | (symbol-name esid) | 6766 | (symbol-name esid) |
| 6765 | (erc-shorten-server-name (or erc-server-announced-name | 6767 | (erc-shorten-server-name (or erc-server-announced-name |
| 6766 | erc-session-server))))) | 6768 | erc-session-server))))) |