>From e4e270a4bf556ce238bc42c8549d4c443f3a969a Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Tue, 7 Feb 2023 00:08:34 -0800 Subject: [PATCH 0/3] *** NOT A PATCH *** *** BLURB HERE *** F. Jason Park (3): [5.6] Don't associate ERC modules with undefined groups [5.6] Warn when setting minor-mode vars for ERC modules [5.6] Fill doc strings for ERC modules. lisp/erc/erc-capab.el | 1 + lisp/erc/erc-common.el | 136 +++++++++++++++++++++++++++++++++---- lisp/erc/erc.el | 3 +- test/lisp/erc/erc-tests.el | 78 ++++++++++++++++----- 4 files changed, 187 insertions(+), 31 deletions(-) Interdiff: diff --git a/lisp/erc/erc-capab.el b/lisp/erc/erc-capab.el index 25cdea9e777..bb0921da7f0 100644 --- a/lisp/erc/erc-capab.el +++ b/lisp/erc/erc-capab.el @@ -89,7 +89,8 @@ erc-capab-identify-unidentified ;;; Define module: ;;;###autoload(autoload 'erc-capab-identify-mode "erc-capab" nil t) -(define-erc-module capab-identify capab +(put 'capab-identify 'erc-group 'erc-capab) +(define-erc-module capab-identify nil "Handle dancer-ircd's CAPAB IDENTIFY-MSG and IDENTIFY-CTCP." ;; append so that `erc-server-parameters' is already set by `erc-server-005' ((add-hook 'erc-server-005-functions #'erc-capab-identify-setup t) diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index f488244ef9c..cc278428d5d 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el @@ -97,7 +97,7 @@ erc--target ;; TODO move goodies modules here after 29 is released. (defconst erc--features-to-modules '((erc-pcomplete completion pcomplete) - (erc-capab capab capab-identify) + (erc-capab capab-identify) (erc-join autojoin) (erc-page page ctcp-page) (erc-sound sound ctcp-sound) @@ -173,23 +173,27 @@ erc--assemble-toggle ;; For corner cases where this fails and where the catch-all of `erc' ;; is inappropriate, (global) modules can declare a top-level ;; -;; (custom-add-to-group 'erc-foo 'erc-bar-mode 'custom-variable) +;; (put 'foo 'erc-group 'erc-bar) ;; -;; *before* the module's definition. If `define-erc-module' ever -;; accepts arbitrary keywords, passing an explicit `:group' will +;; where `erc-bar' is the group and `foo' is the normalized module. +;; Do this *before* the module's definition. If `define-erc-module' +;; ever accepts arbitrary keywords, passing an explicit `:group' will ;; obviously be preferable. (defun erc--find-group (&rest symbols) (catch 'found - (while symbols - (when-let* ((s (pop symbols)) - (downed (concat "erc-" (downcase (symbol-name s)))) - (known (intern-soft downed))) - (when-let ((found (custom-group-of-mode known))) - (throw 'found found)) - (when (or (get known 'group-documentation) - (rassq known custom-current-group-alist)) - (throw 'found known)))) + (dolist (s symbols) + (let* ((downed (downcase (symbol-name s))) + (known (intern-soft (concat "erc-" downed)))) + (when (and known + (or (get known 'group-documentation) + (rassq known custom-current-group-alist))) + (throw 'found known)) + (when (setq known (intern-soft (concat "erc-" downed "-mode"))) + (when-let ((found (custom-group-of-mode known))) + (throw 'found found)))) + (when-let ((found (get (erc--normalize-module-symbol s) 'erc-group))) + (throw 'found found))) 'erc)) (defun erc--custom-set-minor-mode (variable value) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 70ba82fd4bf..5e971f15f5d 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1854,9 +1854,10 @@ erc-modules (const :tag "autojoin: Join channels automatically" autojoin) (const :tag "button: Buttonize URLs, nicknames, and other text" button) (const :tag "capab: Mark unidentified users on servers supporting CAPAB" - capab) + capab-identify) (const :tag "completion: Complete nicknames and commands (programmable)" completion) + (const :tag "hecomplete: Complete nicknames and commands (obsolete, use \"completion\")" hecomplete) (const :tag "dcc: Provide Direct Client-to-Client support" dcc) (const :tag "fill: Wrap long lines" fill) (const :tag "identd: Launch an identd server on port 8113" identd) diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 703b26dcea0..e5db78ef2e1 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -1214,29 +1214,33 @@ erc--find-group (should (eq (erc--find-group 'keep-place nil) 'erc)) (should (eq (erc--find-group 'networks nil) 'erc-networks)) ;; These are fake - (cl-letf (((get 'erc-bar 'group-documentation) "")) + (cl-letf (((get 'erc-bar 'group-documentation) "") + ((get 'baz 'erc-group) 'erc-foo)) (should (eq (erc--find-group 'foo 'bar) 'erc-bar)) (should (eq (erc--find-group 'bar 'foo) 'erc-bar)) (should (eq (erc--find-group 'bar nil) 'erc-bar)) - (should (eq (erc--find-group 'foo nil) 'erc)))) + (should (eq (erc--find-group 'foo nil) 'erc)) + (should (eq (erc--find-group 'fake 'baz) 'erc-foo)))) (ert-deftest erc--find-group--real () :tags '(:unstable) - (let (out) - (pcase-dolist (`(,feat . ,syms) erc--features-to-modules) - (require feat) - (push (cons syms (apply #'erc--find-group syms)) out)) - ;; Remove local modules, which are mapped to the catch-all - (while (and-let* ((m (rassq 'erc out))) ; while-let - (setq out (remq m out)))) - (should (equal out - '(((services nickserv) . erc-services) - ((stamp timestamp) . erc-stamp) - ((sound ctcp-sound) . erc-sound) - ((page ctcp-page) . erc-page) - ((autojoin) . erc-autojoin) - ((capab capab-identify) . erc-capab) - ((completion pcomplete) . erc-pcomplete)))))) + (require 'erc-services) + (require 'erc-stamp) + (require 'erc-sound) + (require 'erc-page) + (require 'erc-join) + (require 'erc-capab) + (require 'erc-pcomplete) + (should (eq (erc--find-group 'services 'nickserv) 'erc-services)) + (should (eq (erc--find-group 'stamp 'timestamp) 'erc-stamp)) + (should (eq (erc--find-group 'sound 'ctcp-sound) 'erc-sound)) + (should (eq (erc--find-group 'page 'ctcp-page) 'erc-page)) + (should (eq (erc--find-group 'autojoin) 'erc-autojoin)) + (should (eq (erc--find-group 'pcomplete 'Completion) 'erc-pcomplete)) + (should (eq (erc--find-group 'capab-identify) 'erc-capab)) + ;; No group specified. + (should (eq (erc--find-group 'smiley nil) 'erc)) + (should (eq (erc--find-group 'unmorse nil) 'erc))) (ert-deftest erc--update-modules () (let (calls -- 2.39.1