1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Use modern fallback for channel name detection in ERC

* lisp/erc/erc-backend.el (erc-query-buffer-p): Remove forward declaration.
* lisp/erc/erc.el (erc-query-buffer-p): Defer to `erc-channel-p'.
(erc-channel-p): Refactor and use `erc--fallback-channel-prefixes' for
the default CHANTYPES value.  Honor an empty CHANTYPES value as valid,
e.g., for servers that only support direct messages.
(erc--fallback-channel-prefixes): New variable to hold fallback
CHANTYPES prefixes recommended by RFC1459 and modern authorities on
the matter.
* test/lisp/erc/erc-tests.el (erc-channel-p): Revise test.  (Bug#67220)
This commit is contained in:
F. Jason Park 2024-02-11 20:01:54 -08:00
parent 25d15391f2
commit 3d87e34327
3 changed files with 42 additions and 33 deletions

View file

@ -1167,25 +1167,37 @@
(should (equal (erc-downcase "\\O/") "|o/" )))))
(ert-deftest erc-channel-p ()
(let ((erc--isupport-params (make-hash-table))
erc-server-parameters)
(erc-tests-common-make-server-buf)
(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"))
(should (erc-channel-p "#chan"))
(should (erc-channel-p "##chan"))
(should (erc-channel-p "&chan"))
(should-not (erc-channel-p "+chan"))
(should-not (erc-channel-p "!chan"))
(should-not (erc-channel-p "@chan"))
(push '("CHANTYPES" . "#&@+!") erc-server-parameters)
;; Server sends "CHANTYPES=#&+!"
(should-not erc-server-parameters)
(setq erc-server-parameters '(("CHANTYPES" . "#&+!")))
(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 (erc-channel-p "#chan"))
(with-current-buffer (erc--open-target "#chan")
(should (erc-channel-p (current-buffer))))
(with-current-buffer (erc--open-target "+chan")
(should (erc-channel-p (current-buffer))))
(should (erc-channel-p (get-buffer "#chan")))
(should (erc-channel-p (get-buffer "+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"))
;; Server sends "CHANTYPES=" because it's query only.
(puthash 'CHANTYPES '("CHANTYPES") erc--isupport-params)
(should-not (erc-channel-p "#spam"))
(should-not (erc-channel-p "&spam"))
(should-not (erc-channel-p (save-excursion (erc--open-target "#spam"))))
(erc-tests-common-kill-buffers))
(ert-deftest erc--valid-local-channel-p ()
(ert-info ("Local channels not supported")