aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2023-02-18 19:32:36 -0800
committerF. Jason Park2023-04-08 14:23:50 -0700
commite69bd59ec59784b2f646e93355d4d63f41426cfc (patch)
treefff6062e04cf60606943301ca0528b895ef78350
parent8c0c98268440b27a77faf30738dfd72c909bb33f (diff)
downloademacs-e69bd59ec59784b2f646e93355d4d63f41426cfc.tar.gz
emacs-e69bd59ec59784b2f646e93355d4d63f41426cfc.zip
Honor arbitrary CHANTYPES in ERC
* lisp/erc/erc.el (erc-channel-p): Favor "CHANTYPES" ISUPPORT item before falling back to well known prefixes. * test/lisp/erc/erc-tests.el (erc-channel-p): Add test. Arbitrarily bundled with bug#60954.
-rw-r--r--lisp/erc/erc.el12
-rw-r--r--test/lisp/erc/erc-tests.el21
2 files changed, 29 insertions, 4 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 6d35a62518d..ef51f100f8b 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1549,10 +1549,14 @@ effect when `erc-join-buffer' is set to `frame'."
1549(defun erc-channel-p (channel) 1549(defun erc-channel-p (channel)
1550 "Return non-nil if CHANNEL seems to be an IRC channel name." 1550 "Return non-nil if CHANNEL seems to be an IRC channel name."
1551 (cond ((stringp channel) 1551 (cond ((stringp channel)
1552 (memq (aref channel 0) '(?# ?& ?+ ?!))) 1552 (memq (aref channel 0)
1553 ((and (bufferp channel) (buffer-live-p channel)) 1553 (if-let ((types (erc--get-isupport-entry 'CHANTYPES 'single)))
1554 (with-current-buffer channel 1554 (append types nil)
1555 (erc-channel-p (erc-default-target)))) 1555 '(?# ?& ?+ ?!))))
1556 ((and-let* (((bufferp channel))
1557 ((buffer-live-p channel))
1558 (target (buffer-local-value 'erc--target channel)))
1559 (erc-channel-p (erc--target-string target))))
1556 (t nil))) 1560 (t nil)))
1557 1561
1558;; For the sake of compatibility, a historical quirk concerning this 1562;; For the sake of compatibility, a historical quirk concerning this
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index d6c63934163..bbf3269161d 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -447,6 +447,27 @@
447 (should (equal (erc-downcase "Tilde~") "tilde~" )) 447 (should (equal (erc-downcase "Tilde~") "tilde~" ))
448 (should (equal (erc-downcase "\\O/") "|o/" ))))) 448 (should (equal (erc-downcase "\\O/") "|o/" )))))
449 449
450(ert-deftest erc-channel-p ()
451 (let ((erc--isupport-params (make-hash-table))
452 erc-server-parameters)
453
454 (should (erc-channel-p "#chan"))
455 (should (erc-channel-p "##chan"))
456 (should (erc-channel-p "&chan"))
457 (should (erc-channel-p "+chan"))
458 (should (erc-channel-p "!chan"))
459 (should-not (erc-channel-p "@chan"))
460
461 (push '("CHANTYPES" . "#&@+!") erc-server-parameters)
462
463 (should (erc-channel-p "!chan"))
464 (should (erc-channel-p "#chan"))
465
466 (with-current-buffer (get-buffer-create "#chan")
467 (setq erc--target (erc--target-from-string "#chan")))
468 (should (erc-channel-p (get-buffer "#chan"))))
469 (kill-buffer "#chan"))
470
450(ert-deftest erc--valid-local-channel-p () 471(ert-deftest erc--valid-local-channel-p ()
451 (ert-info ("Local channels not supported") 472 (ert-info ("Local channels not supported")
452 (let ((erc--isupport-params (make-hash-table))) 473 (let ((erc--isupport-params (make-hash-table)))