[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e69bd59ec59 09/37: Honor arbitrary CHANTYPES in ERC
From: |
F. Jason Park |
Subject: |
master e69bd59ec59 09/37: Honor arbitrary CHANTYPES in ERC |
Date: |
Sat, 8 Apr 2023 17:31:28 -0400 (EDT) |
branch: master
commit e69bd59ec59784b2f646e93355d4d63f41426cfc
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
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.
---
lisp/erc/erc.el | 12 ++++++++----
test/lisp/erc/erc-tests.el | 21 +++++++++++++++++++++
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'."
(defun erc-channel-p (channel)
"Return non-nil if CHANNEL seems to be an IRC channel name."
(cond ((stringp channel)
- (memq (aref channel 0) '(?# ?& ?+ ?!)))
- ((and (bufferp channel) (buffer-live-p channel))
- (with-current-buffer channel
- (erc-channel-p (erc-default-target))))
+ (memq (aref channel 0)
+ (if-let ((types (erc--get-isupport-entry 'CHANTYPES 'single)))
+ (append types nil)
+ '(?# ?& ?+ ?!))))
+ ((and-let* (((bufferp channel))
+ ((buffer-live-p channel))
+ (target (buffer-local-value 'erc--target channel)))
+ (erc-channel-p (erc--target-string target))))
(t nil)))
;; 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 @@
(should (equal (erc-downcase "Tilde~") "tilde~" ))
(should (equal (erc-downcase "\\O/") "|o/" )))))
+(ert-deftest erc-channel-p ()
+ (let ((erc--isupport-params (make-hash-table))
+ erc-server-parameters)
+
+ (should (erc-channel-p "#chan"))
+ (should (erc-channel-p "##chan"))
+ (should (erc-channel-p "&chan"))
+ (should (erc-channel-p "+chan"))
+ (should (erc-channel-p "!chan"))
+ (should-not (erc-channel-p "@chan"))
+
+ (push '("CHANTYPES" . "#&@+!") erc-server-parameters)
+
+ (should (erc-channel-p "!chan"))
+ (should (erc-channel-p "#chan"))
+
+ (with-current-buffer (get-buffer-create "#chan")
+ (setq erc--target (erc--target-from-string "#chan")))
+ (should (erc-channel-p (get-buffer "#chan"))))
+ (kill-buffer "#chan"))
+
(ert-deftest erc--valid-local-channel-p ()
(ert-info ("Local channels not supported")
(let ((erc--isupport-params (make-hash-table)))
- master 0d3ccdbde44 16/37: Don't associate ERC modules with undefined groups, (continued)
- master 0d3ccdbde44 16/37: Don't associate ERC modules with undefined groups, F. Jason Park, 2023/04/08
- master 3a012d1db24 21/37: Add display option for interactive ERC invocations, F. Jason Park, 2023/04/08
- master dfaeeba97cc 01/37: Change ERC version to 5.6-git, F. Jason Park, 2023/04/08
- master 03eddc99242 07/37: Add probing erc-server-reconnect-function variant, F. Jason Park, 2023/04/08
- master b1007516cdf 02/37: Add subcommand dispatch facility to erc-cmd-HELP, F. Jason Park, 2023/04/08
- master 2d876a4ca94 15/37: Convert ERC's Imenu integration into proper module, F. Jason Park, 2023/04/08
- master 61ed0b43cdb 05/37: Split overlong outgoing messages in erc-sasl, F. Jason Park, 2023/04/08
- master 8184a815aff 34/37: Add erc-button helper for substituting command keys, F. Jason Park, 2023/04/08
- master 379d35695b1 28/37: Make some erc-stamp functions more limber, F. Jason Park, 2023/04/08
- master 1f1cd467c6a 33/37: Replace Info-goto-node with info in erc-button-alist, F. Jason Park, 2023/04/08
- master e69bd59ec59 09/37: Honor arbitrary CHANTYPES in ERC,
F. Jason Park <=
- master d5435a0d822 25/37: Refactor marker initialization in erc-open, F. Jason Park, 2023/04/08
- master 5011554529b 12/37: Don't require erc-goodies in erc.el, F. Jason Park, 2023/04/08
- master 0e4c07dc744 36/37: Allow erc-reuse-frames to favor connections, F. Jason Park, 2023/04/08
- master 89815631f24 10/37: Copy over upstream Compat macros to erc-compat, F. Jason Park, 2023/04/08
- master 9aa2806fdc3 13/37: Modify erc-mode-map in module definitions, F. Jason Park, 2023/04/08
- master 8793874616f 26/37: Adjust some old text properties in ERC buffers, F. Jason Park, 2023/04/08
- master 3d81ecf0a95 11/37: Leverage loaddefs for migrating ERC modules, F. Jason Park, 2023/04/08
- master 9f6a9cef97b 29/37: Put display properties to better use in erc-stamp, F. Jason Park, 2023/04/08
- master e3c4a648d16 31/37: Add variant for erc-match invisibility spec, F. Jason Park, 2023/04/08
- master c104e90888a 35/37: Make auth-source erc-services tests more readable, F. Jason Park, 2023/04/08