From: F. Jason Park Date: Sat, 7 Dec 2024 03:09:04 +0000 (-0800) Subject: ; Slightly improve test case for erc-parse-modes X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b16218d5e62126e501cb2ea34765824d0f012647;p=emacs.git ; 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) --- 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")))))