[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1c24af0fcb 12/25: Add helper to determine local channels in ERC
From: |
F. Jason Park |
Subject: |
master 1c24af0fcb 12/25: Add helper to determine local channels in ERC |
Date: |
Thu, 30 Jun 2022 18:29:53 -0400 (EDT) |
branch: master
commit 1c24af0fcb8a8326fe5cdc75672bf4099b191a00
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Add helper to determine local channels in ERC
* lisp/erc/erc.el (erc--valid-local-channel-p): Add internal helper to
determine whether an IRC channel is local according to its network's
CHANTYPES ISUPPORT parameter.
* test/lisp/erc/erc-tests.el (erc--valid-local-channel-p): Add test
for this helper.
---
lisp/erc/erc.el | 8 ++++++++
test/lisp/erc/erc-tests.el | 12 ++++++++++++
2 files changed, 20 insertions(+)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 4c54ef2ef9..d4cf28a86d 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -3251,6 +3251,14 @@ For a list of user commands (/join /part, ...):
(concat " " password)
"")))))
+(defun erc--valid-local-channel-p (channel)
+ "Non-nil when channel is server-local on a network that allows them."
+ (and-let* (((eq ?& (aref channel 0)))
+ (chan-types (erc--get-isupport-entry 'CHANTYPES 'single))
+ ((if (>= emacs-major-version 28)
+ (string-search "&" chan-types)
+ (string-match-p "&" chan-types))))))
+
(defun erc-cmd-JOIN (channel &optional key)
"Join the channel given in CHANNEL, optionally with KEY.
If CHANNEL is specified as \"-invite\", join the channel to which you
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index cffb61f708..4026ebaf33 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -466,6 +466,18 @@
(should (equal (erc-downcase "Tilde~") "tilde~" ))
(should (equal (erc-downcase "\\O/") "|o/" )))))
+(ert-deftest erc--valid-local-channel-p ()
+ (ert-info ("Local channels not supported")
+ (let ((erc--isupport-params (make-hash-table)))
+ (puthash 'CHANTYPES '("#") erc--isupport-params)
+ (should-not (erc--valid-local-channel-p "#chan"))
+ (should-not (erc--valid-local-channel-p "&local"))))
+ (ert-info ("Local channels supported")
+ (let ((erc--isupport-params (make-hash-table)))
+ (puthash 'CHANTYPES '("&#") erc--isupport-params)
+ (should-not (erc--valid-local-channel-p "#chan"))
+ (should (erc--valid-local-channel-p "&local")))))
+
(ert-deftest erc-ring-previous-command-base-case ()
(ert-info ("Create ring when nonexistent and do nothing")
(let (erc-input-ring
- master a63ed6f78a 04/25: Remove duplicate ERC prompt on reconnect, (continued)
- master a63ed6f78a 04/25: Remove duplicate ERC prompt on reconnect, F. Jason Park, 2022/06/30
- master de53d18a4d 07/25: Don't set erc-server-announced-name unless known, F. Jason Park, 2022/06/30
- master 873499ce06 06/25: Allow exemption from flood penalty in erc-backend, F. Jason Park, 2022/06/30
- master ecafe1cbb5 10/25: Recognize ASCII and strict CASEMAPPINGs in ERC, F. Jason Park, 2022/06/30
- master 752e860db4 16/25: Address long-standing ERC buffer-naming issues, F. Jason Park, 2022/06/30
- master 85c2f3bc3e 25/25: Update ERC's Info doc with network-ID related changes, F. Jason Park, 2022/06/30
- master 54414ec846 02/25: Initialize erc-server-filter-data in erc-backend, F. Jason Park, 2022/06/30
- master 4e312c07f7 11/25: Make ERC respect spaces in server passwords, F. Jason Park, 2022/06/30
- master 485b84cb7c 08/25: Require erc-networks in erc.el, F. Jason Park, 2022/06/30
- master c356f86b51 09/25: Update ISUPPORT handling in ERC, F. Jason Park, 2022/06/30
- master 1c24af0fcb 12/25: Add helper to determine local channels in ERC,
F. Jason Park <=
- master 529e46f128 13/25: Add eventual replacement for erc-default-recipients, F. Jason Park, 2022/06/30
- master 1767b0bd7e 19/25: Don't call erc-auto-query twice on PRIVMSG, F. Jason Park, 2022/06/30
- master 7c47d6c52d 18/25: Register erc-kill-buffer-function locally, F. Jason Park, 2022/06/30
- master 10237840d0 24/25: Optionally prevent sending multiline input in ERC, F. Jason Park, 2022/06/30
- master 9be08ceb31 15/25: Add ERC test server and related resources, F. Jason Park, 2022/06/30
- master 922ad23840 17/25: Add user-oriented test scenarios for ERC, F. Jason Park, 2022/06/30
- master e958a2b726 14/25: Discourage ill-defined use of buffer targets in ERC, F. Jason Park, 2022/06/30
- master 959fbcf34b 20/25: Favor network identities in erc-join, F. Jason Park, 2022/06/30
- master a9d89d083a 22/25: Fix regression in erc-send-input-line, F. Jason Park, 2022/06/30
- master 0590224343 21/25: Standardize auth-source queries in ERC, F. Jason Park, 2022/06/30