From 297df95338694a0af1614dc92ae9c1391bc20a90 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 14 Nov 2022 00:02:39 -0800 Subject: [PATCH 0/5] *** NOT A PATCH *** *** BLURB HERE *** F. Jason Park (5): Add GS2 authorization to sasl-scram-rfc Don't set erc-networks--id until network is known Support local ERC modules in erc-mode buffers Call erc-login indirectly via new generic wrapper Add non-IRCv3 SASL module to ERC doc/misc/erc.texi | 148 +++++- etc/ERC-NEWS | 20 +- lisp/erc/erc-backend.el | 15 +- lisp/erc/erc-common.el | 56 ++- lisp/erc/erc-compat.el | 116 +++++ lisp/erc/erc-goodies.el | 1 + lisp/erc/erc-networks.el | 39 +- lisp/erc/erc-sasl.el | 433 ++++++++++++++++++ lisp/erc/erc.el | 86 ++-- lisp/net/sasl-scram-rfc.el | 21 +- test/lisp/erc/erc-sasl-tests.el | 319 +++++++++++++ test/lisp/erc/erc-scenarios-sasl.el | 208 +++++++++ test/lisp/erc/erc-tests.el | 58 +++ test/lisp/erc/resources/sasl/external.eld | 33 ++ test/lisp/erc/resources/sasl/plain-failed.eld | 16 + test/lisp/erc/resources/sasl/plain.eld | 39 ++ test/lisp/erc/resources/sasl/scram-sha-1.eld | 47 ++ .../lisp/erc/resources/sasl/scram-sha-256.eld | 47 ++ 18 files changed, 1616 insertions(+), 86 deletions(-) create mode 100644 lisp/erc/erc-sasl.el create mode 100644 test/lisp/erc/erc-sasl-tests.el create mode 100644 test/lisp/erc/erc-scenarios-sasl.el create mode 100644 test/lisp/erc/resources/sasl/external.eld create mode 100644 test/lisp/erc/resources/sasl/plain-failed.eld create mode 100644 test/lisp/erc/resources/sasl/plain.eld create mode 100644 test/lisp/erc/resources/sasl/scram-sha-1.eld create mode 100644 test/lisp/erc/resources/sasl/scram-sha-256.eld Interdiff: diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS index f5b14376ad..f35e94dc1f 100644 --- a/etc/ERC-NEWS +++ b/etc/ERC-NEWS @@ -103,12 +103,11 @@ impact on the user experience, but third-party packages may wish to take note. More importantly, the function 'erc-update-modules' now supports an -optional argument to defer the enabling of local modules and instead -return their mode-activation commands. 'erc-open' leverages this new -functionality to delay their activation, as well as that of all -'erc-mode-hook' members, until most of ERC's mode-related variables -have been initialized. This does not include connection-specific -variables defined in erc-backend, however. +optional argument to defer enabling of local modules and instead +return their mode commands. 'erc-open' leverages this to delay their +activation, as well as that of all 'erc-mode-hook' members, until most +local session variables have been initialized (minus those "server"- +and process-focused ones in erc-backend). ** Miscellaneous behavioral changes in the library API. A number of core macros and other definitions have been moved to a new diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index c5989dbc7e..6a9bd56794 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1869,9 +1869,7 @@ erc-update-modules modules, possibly for deferred invocation, as done by `erc-open' whenever a new ERC buffer is created. Local modules were introduced in ERC 5.5." - (let ((local-modes - (when (and defer-locals (derived-mode-p 'erc-mode)) - (erc-compat--local-module-modes)))) + (let (local-modes) (dolist (module erc-modules (and defer-locals local-modes)) (require (or (alist-get module erc--modules-to-features) (intern (concat "erc-" (symbol-name module)))) @@ -1880,7 +1878,7 @@ erc-update-modules (unless (and mode (fboundp mode)) (error "`%s' is not a known ERC module" module)) (if (and defer-locals (not (custom-variable-p mode))) - (cl-pushnew mode local-modes) + (push mode local-modes) (funcall mode 1)))))) (defun erc-setup-buffer (buffer) @@ -1948,7 +1946,10 @@ erc-open (when connect (run-hook-with-args 'erc-before-connect server port nick)) (set-buffer buffer) (setq old-point (point)) - (setq delayed-modules (erc-update-modules 'defer-locals)) + (setq delayed-modules + (delete-dups (append (when continued-session + (erc-compat--local-module-modes)) + (erc-update-modules 'defer-locals)))) (delay-mode-hooks (erc-mode)) diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 91815b8fae..3221af03ed 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -998,22 +998,17 @@ erc-update-modules (should (equal (nreverse calls) '( erc-pcomplete (completion . 1) erc-join (autojoin . 1) erc-networks (networks . 1)))) - (setq calls nil)) + (setq calls nil))))) - (ert-info ("Reenabling of local minor modes by `erc-open'") - (with-temp-buffer - (erc-mode) - (setq erc-modules '(completion autojoin networks)) - (if (< 27 emacs-major-version) - (let ((local-minor-modes '(font-lock-mode erc-fake-bar-mode))) - (should (equal (erc-update-modules t) '(erc-fake-bar-mode)))) - (cl-letf (((symbol-function 'buffer-local-variables) - (lambda (&rest _) '((font-lock-mode) - (erc-fake-bar-mode))))) - (should (equal (erc-update-modules t) '(erc-fake-bar-mode))))) - (should (equal (nreverse calls) - '( erc-pcomplete (completion . 1) - erc-join (autojoin . 1) - erc-networks (networks . 1))))))))) +(ert-deftest erc-compat--local-module-modes () + (with-temp-buffer + (if (< 27 emacs-major-version) + (let ((local-minor-modes '(font-lock-mode erc-fake-bar-mode))) + (should (equal (erc-compat--local-module-modes) + '(erc-fake-bar-mode)))) + (cl-letf (((symbol-function 'buffer-local-variables) + (lambda (&rest _) '((font-lock-mode) (erc-fake-bar-mode))))) + (should (equal (erc-compat--local-module-modes) + '(erc-fake-bar-mode))))))) ;;; erc-tests.el ends here -- 2.38.1