From b16218d5e62126e501cb2ea34765824d0f012647 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Fri, 6 Dec 2024 19:09:04 -0800 Subject: [PATCH] ; Slightly improve test case for erc-parse-modes * lisp/erc/erc.el (erc--merge-local-modes): Look for a symbol's `erc-module' property before examining its name. * test/lisp/erc/erc-tests.el (erc-parse-modes): Expand case to cover alternating plus and minus mode changes. (cherry picked from commit dc7c38ed9ec85e2e7cbe3c9fcb3b6d5dbb5aa206) --- lisp/erc/erc.el | 6 +++--- test/lisp/erc/erc-tests.el | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 9d70264b36a..10b5fc84da9 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2519,9 +2519,9 @@ nil." (if old-vars (let ((out (list (reverse new-modes)))) (pcase-dolist (`(,k . ,v) old-vars) - (when (and (string-prefix-p "erc-" (symbol-name k)) - (string-suffix-p "-mode" (symbol-name k)) - (get k 'erc-module)) + (when (and (get k 'erc-module) + (string-prefix-p "erc-" (symbol-name k)) + (string-suffix-p "-mode" (symbol-name k))) (if v (cl-pushnew k (car out)) (setf (car out) (delq k (car out))) diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 35ad5c8d621..1968a75136f 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -825,8 +825,11 @@ (should (equal (erc-parse-modes "-o bob") '(nil nil (("o" off "bob"))))) (should (equal (erc-parse-modes "+uo bob") '(("u") nil (("o" on "bob"))))) (should (equal (erc-parse-modes "+o-u bob") '(nil ("u") (("o" on "bob"))))) + (should (equal (erc-parse-modes "+uo-tv bob alice") '(("u") ("t") (("o" on "bob") ("v" off "alice"))))) + (should (equal (erc-parse-modes "+u-t+o-v bob alice") + '(("u") ("t") (("o" on "bob") ("v" off "alice"))))) (ert-info ("Modes of type B are always grouped as unary") (should (equal (erc-parse-modes "+k h2") '(nil nil (("k" on "h2"))))) -- 2.39.2