[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix/bug-48598 911481d449 13/27: Add helper to determine local channels i
From: |
F. Jason Park |
Subject: |
fix/bug-48598 911481d449 13/27: Add helper to determine local channels in ERC |
Date: |
Fri, 8 Apr 2022 03:06:48 -0400 (EDT) |
branch: fix/bug-48598
commit 911481d4492ed9a5b38a0317ab337bee97370b81
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 helper to determine
whether some channel is local according to network's CHANTYPES param.
---
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 8835e06bba..131850c19a 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -3240,6 +3240,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 4fd04651ca..ff232577e9 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -423,6 +423,18 @@
(should (equal (erc-downcase "Tilde~") "tilde~" ))
(should (equal (erc-downcase "\\O/") "|o/" )))))
+(ert-deftest erc-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
- branch fix/bug-48598 created (now ab2d93e564), F. Jason Park, 2022/04/08
- fix/bug-48598 b16a07dce1 03/27: Accept user keyword arg in ERC entry-point commands, F. Jason Park, 2022/04/08
- fix/bug-48598 8b7760d301 07/27: Allow exemption from flood penalty in erc-backend, F. Jason Park, 2022/04/08
- fix/bug-48598 57eedf46ae 04/27: Add some ERC test helpers, F. Jason Park, 2022/04/08
- fix/bug-48598 911481d449 13/27: Add helper to determine local channels in ERC,
F. Jason Park <=
- fix/bug-48598 eee86bc7d7 16/27: Add ERC test server and related resources, F. Jason Park, 2022/04/08
- fix/bug-48598 7cb4eec8a1 23/27: SQUASH-ME: Add ERC test scenarios for identity-aware autojoin, F. Jason Park, 2022/04/08
- fix/bug-48598 447bc23d7b 21/27: SQUASH-ME: Add ERC scenarios for identity-aware msg handlers, F. Jason Park, 2022/04/08
- fix/bug-48598 a999ff61fa 19/27: Register erc-kill-buffer-function locally, F. Jason Park, 2022/04/08
- fix/bug-48598 e0bf4383d7 24/27: Standardize auth-source queries in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 1978c3178c 10/27: Update ISUPPORT handling in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 6ee4329b46 02/27: Initialize erc-server-filter-data in erc-backend, F. Jason Park, 2022/04/08
- fix/bug-48598 3c6694d114 20/27: Don't call erc-auto-query twice on PRIVMSG, F. Jason Park, 2022/04/08
- fix/bug-48598 50b3aa88fc 11/27: Recognize ascii and strict CASEMAPPINGs in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 f9794dea43 15/27: Discourage ill-defined use of buffer targets in ERC, F. Jason Park, 2022/04/08