diff options
| author | F. Jason Park | 2023-05-30 23:27:12 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-07-13 18:45:31 -0700 |
| commit | b354b3a53bfbb30dc4f98fe9947f3ba939e1436d (patch) | |
| tree | 05dd44b080dd5977d0384ab12b896ffc51b47849 /test/lisp | |
| parent | d45770e8d03ae82d44d05086e22d552ab60e34e9 (diff) | |
| download | emacs-b354b3a53bfbb30dc4f98fe9947f3ba939e1436d.tar.gz emacs-b354b3a53bfbb30dc4f98fe9947f3ba939e1436d.zip | |
Allow custom display-buffer actions in ERC
* doc/misc/erc.texi: Add new section under "Integrations" chapter
describing `display-buffer' Custom function choice for ERC's many
buffer-display options.
* etc/ERC-NEWS: Mention new function variant for all buffer-display
options.
* lisp/erc/erc-backend.el: Add forward declaration for
`erc--called-as-input-p' and `erc--display-context'.
(erc--server-reconnect-display-timer,
erc--server-last-reconnect-display-reset): Use new name for option
`erc-reconnect-display', now `erc-auto-reconnect-display'.
(erc--server-determine-join-display-context): New generic function to
determine value of `erc--display-context' during JOINs.
(erc-server-JOIN, erc-server-PRIVMSG): Set `erc--display-context' to a
symbol for the handler's IRC command, like `JOIN', for the benefit of
custom `display-buffer'-like functions running in `erc-setup-buffer'.
(erc-server-471, erc-server-471-functions, erc-server-473,
erc-server-473-functions): New handlers for JOIN rejections. Also
remove 471 and 473 from comment at bottom of file.
(erc-server-475): Bind `erc--called-as-input-p' so that `erc-cmd-JOIN'
sets `erc-interactive-display' context.
* lisp/erc/erc-join.el (erc-autojoin-mode, erc-autojoin-enable,
erc-autojoin-disable): Kill local variable
`erc-join--requested-channels'. Add and remove
`erc-join--remove-requested-channels' to/from various server-handler
hooks for JOIN rejection numerics.
(erc-join--requested-channels): New local variable to remember
channels we've attempted to JOIN this session that haven't yet been
confirmed by the server.
(erc-join--remove-requested-channel): New JOIN rejection handler to
stop tracking channel in `erc-join--requested-channels'.
(erc--server-determine-join-display-context): module-specific
implementation of generic function for `erc-autojoin-mode'.
(erc-autojoin--join): Remember channels slated for JOIN'ing.
* lisp/erc/erc.el (erc--buffer-display-choices): New helper constant
for defining common `:type' for all buffer-display options.
(erc-buffer-display, erc-interactive-display,
erc-auto-reconnect-display, erc-receive-query-display): Use helper
`erc--buffer-display-choices' for defining `:type', which
includes a new choice for a `display-buffer'-like function.
(erc-reconnect-display, erc-auto-reconnect-display): Alias former to
latter, now the preferred name.
(erc-reconnect-timeout, erc-auto-reconnect-timeout): Change name from
former to latter. This option is new in ERC 5.6.
(erc-reconnect-display-server-buffers): New option.
(erc-buffer-do): Revise doc string.
(erc--display-context): New variable, an alist of "context tokens" to
be forwarded as the "action alist" to `erc-buffer-display' functions.
(erc-skip-displaying-selected-window-buffer): New variable, deprecated
at birth, to act as an escape hatch for folks who don't want to skip
the displaying of buffers already showing in the selected window.
(erc--display-buffer-overriding-action): Local variable allowing
modules to influence the displaying of new ERC buffers independently
of user options.
(erc-setup-buffer): Do nothing when the selected window already shows
current buffer unless user has provided a custom display function.
Accommodate new Custom choice function values, like `display-buffer'
and `pop-to-buffer'.
(erc-open): Run `erc-setup-buffer' when option
`erc-reconnect-display-server-buffers' is non-nil, even for existing
server buffers. Bind `display-buffer-overriding-action' to the value
of `erc--display-buffer-overriding-action' around calls to
`erc-setup-buffer'.
(erc-select-read-args): Add `erc--display-context' to environment.
(erc, erc-tls): Bind `erc--display-context' around calls to
`erc-select-read-args' and main body.
(erc-cmd-JOIN, erc-cmd-QUERY, erc--cmd-reconnect, erc-handle-irc-url):
Add item for `erc-interactive-display' to `erc--display-context'.
(erc-connection-established): Update name of
`erc-reconnect-display-timeout' to
`erc-auto-reconnect-display-timeout'.
(erc-message-english-s471, erc-message-english-s473): New variables,
format templates for JOIN rejection messages.
* test/lisp/erc/erc-scenarios-base-buffer-display.el
(erc-scenarios-base-buffer-display--defwin-recbury-intbuf,
erc-scenarios-base-buffer-display--defwino-recbury-intbuf,
erc-scenarios-base-buffer-display--count-reset-timeout): Use preferred
name `erc-auto-reconnect-display' for `erc-reconnect-display'.
* test/lisp/erc/erc-scenarios-join-display-context.el: New file.
* test/lisp/erc/erc-tests.el (erc--initialize-markers): Fix
unrealistic call to `erc-open'.
(erc-setup-buffer--custom-action): New test.
(erc-select-read-args, erc-tls, erc--interactive, erc-server-select):
Expect new environment binding for `erc--display-context'.
* test/lisp/erc/resources/join/buffer-display/mode-context.eld: New
file. (Bug#62833)
Diffstat (limited to 'test/lisp')
| -rw-r--r-- | test/lisp/erc/erc-scenarios-base-buffer-display.el | 28 | ||||
| -rw-r--r-- | test/lisp/erc/erc-scenarios-join-display-context.el | 66 | ||||
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 90 | ||||
| -rw-r--r-- | test/lisp/erc/resources/join/buffer-display/mode-context.eld | 38 |
4 files changed, 196 insertions, 26 deletions
diff --git a/test/lisp/erc/erc-scenarios-base-buffer-display.el b/test/lisp/erc/erc-scenarios-base-buffer-display.el index 548ad00e2d9..df292a8c113 100644 --- a/test/lisp/erc/erc-scenarios-base-buffer-display.el +++ b/test/lisp/erc/erc-scenarios-base-buffer-display.el | |||
| @@ -26,8 +26,8 @@ | |||
| 26 | 26 | ||
| 27 | (eval-when-compile (require 'erc-join)) | 27 | (eval-when-compile (require 'erc-join)) |
| 28 | 28 | ||
| 29 | ;; These first couple `erc-reconnect-display' tests used to live in | 29 | ;; These first couple `erc-auto-reconnect-display' tests used to live |
| 30 | ;; erc-scenarios-base-reconnect but have since been renamed. | 30 | ;; in erc-scenarios-base-reconnect but have since been renamed. |
| 31 | 31 | ||
| 32 | (defun erc-scenarios-base-buffer-display--reconnect-common | 32 | (defun erc-scenarios-base-buffer-display--reconnect-common |
| 33 | (assert-server assert-chan assert-rest) | 33 | (assert-server assert-chan assert-rest) |
| @@ -80,11 +80,11 @@ | |||
| 80 | :tags '(:expensive-test) | 80 | :tags '(:expensive-test) |
| 81 | (should (eq erc-buffer-display 'bury)) | 81 | (should (eq erc-buffer-display 'bury)) |
| 82 | (should (eq erc-interactive-display 'window)) | 82 | (should (eq erc-interactive-display 'window)) |
| 83 | (should-not erc-reconnect-display) | 83 | (should-not erc-auto-reconnect-display) |
| 84 | 84 | ||
| 85 | (let ((erc-buffer-display 'window) | 85 | (let ((erc-buffer-display 'window) |
| 86 | (erc-interactive-display 'buffer) | 86 | (erc-interactive-display 'buffer) |
| 87 | (erc-reconnect-display 'bury)) | 87 | (erc-auto-reconnect-display 'bury)) |
| 88 | 88 | ||
| 89 | (erc-scenarios-base-buffer-display--reconnect-common | 89 | (erc-scenarios-base-buffer-display--reconnect-common |
| 90 | 90 | ||
| @@ -104,7 +104,7 @@ | |||
| 104 | ;; A manual /JOIN command tells ERC we're done auto-reconnecting | 104 | ;; A manual /JOIN command tells ERC we're done auto-reconnecting |
| 105 | (with-current-buffer "FooNet" (erc-scenarios-common-say "/JOIN #spam")) | 105 | (with-current-buffer "FooNet" (erc-scenarios-common-say "/JOIN #spam")) |
| 106 | 106 | ||
| 107 | (ert-info ("#spam ignores `erc-reconnect-display'") | 107 | (ert-info ("#spam ignores `erc-auto-reconnect-display'") |
| 108 | ;; Uses `erc-interactive-display' instead. | 108 | ;; Uses `erc-interactive-display' instead. |
| 109 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) | 109 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) |
| 110 | (should (eq (window-buffer) (get-buffer "#spam"))) | 110 | (should (eq (window-buffer) (get-buffer "#spam"))) |
| @@ -115,10 +115,10 @@ | |||
| 115 | :tags '(:expensive-test) | 115 | :tags '(:expensive-test) |
| 116 | (should (eq erc-buffer-display 'bury)) | 116 | (should (eq erc-buffer-display 'bury)) |
| 117 | (should (eq erc-interactive-display 'window)) | 117 | (should (eq erc-interactive-display 'window)) |
| 118 | (should-not erc-reconnect-display) | 118 | (should-not erc-auto-reconnect-display) |
| 119 | 119 | ||
| 120 | (let ((erc-buffer-display 'window-noselect) | 120 | (let ((erc-buffer-display 'window-noselect) |
| 121 | (erc-reconnect-display 'bury) | 121 | (erc-auto-reconnect-display 'bury) |
| 122 | (erc-interactive-display 'buffer)) | 122 | (erc-interactive-display 'buffer)) |
| 123 | (erc-scenarios-base-buffer-display--reconnect-common | 123 | (erc-scenarios-base-buffer-display--reconnect-common |
| 124 | 124 | ||
| @@ -155,7 +155,7 @@ | |||
| 155 | (should (eq (window-buffer) (get-buffer "bob"))) | 155 | (should (eq (window-buffer) (get-buffer "bob"))) |
| 156 | (should (frame-root-window-p (selected-window))))) | 156 | (should (frame-root-window-p (selected-window))))) |
| 157 | 157 | ||
| 158 | (ert-info ("Newly joined chan ignores `erc-reconnect-display'") | 158 | (ert-info ("Newly joined chan ignores `erc-auto-reconnect-display'") |
| 159 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) | 159 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) |
| 160 | (should (eq (window-buffer) (get-buffer "bob"))) | 160 | (should (eq (window-buffer) (get-buffer "bob"))) |
| 161 | (should-not (frame-root-window-p (selected-window))) | 161 | (should-not (frame-root-window-p (selected-window))) |
| @@ -165,13 +165,13 @@ | |||
| 165 | :tags '(:expensive-test) | 165 | :tags '(:expensive-test) |
| 166 | (should (eq erc-buffer-display 'bury)) | 166 | (should (eq erc-buffer-display 'bury)) |
| 167 | (should (eq erc-interactive-display 'window)) | 167 | (should (eq erc-interactive-display 'window)) |
| 168 | (should (eq erc-reconnect-display-timeout 10)) | 168 | (should (eq erc-auto-reconnect-display-timeout 10)) |
| 169 | (should-not erc-reconnect-display) | 169 | (should-not erc-auto-reconnect-display) |
| 170 | 170 | ||
| 171 | (let ((erc-buffer-display 'window-noselect) | 171 | (let ((erc-buffer-display 'window-noselect) |
| 172 | (erc-reconnect-display 'bury) | 172 | (erc-auto-reconnect-display 'bury) |
| 173 | (erc-interactive-display 'buffer) | 173 | (erc-interactive-display 'buffer) |
| 174 | (erc-reconnect-display-timeout 0.5)) | 174 | (erc-auto-reconnect-display-timeout 0.5)) |
| 175 | (erc-scenarios-base-buffer-display--reconnect-common | 175 | (erc-scenarios-base-buffer-display--reconnect-common |
| 176 | #'ignore #'ignore ; These two are identical to the previous test. | 176 | #'ignore #'ignore ; These two are identical to the previous test. |
| 177 | 177 | ||
| @@ -188,10 +188,10 @@ | |||
| 188 | (erc-d-t-wait-for 1 (null erc--server-reconnect-display-timer)) | 188 | (erc-d-t-wait-for 1 (null erc--server-reconnect-display-timer)) |
| 189 | (erc-cmd-JOIN "#spam"))) | 189 | (erc-cmd-JOIN "#spam"))) |
| 190 | 190 | ||
| 191 | (ert-info ("Newly joined chan ignores `erc-reconnect-display'") | 191 | (ert-info ("Newly joined chan ignores `erc-auto-reconnect-display'") |
| 192 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) | 192 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) |
| 193 | (should (eq (window-buffer) (messages-buffer))) | 193 | (should (eq (window-buffer) (messages-buffer))) |
| 194 | ;; If `erc-reconnect-display-timeout' were left alone, this | 194 | ;; If `erc-auto-reconnect-display-timeout' were left alone, this |
| 195 | ;; would be (frame-root-window-p #<window 1 on *scratch*>). | 195 | ;; would be (frame-root-window-p #<window 1 on *scratch*>). |
| 196 | (should-not (frame-root-window-p (selected-window))) | 196 | (should-not (frame-root-window-p (selected-window))) |
| 197 | (should (eq (current-buffer) (window-buffer (next-window)))))))))) | 197 | (should (eq (current-buffer) (window-buffer (next-window)))))))))) |
diff --git a/test/lisp/erc/erc-scenarios-join-display-context.el b/test/lisp/erc/erc-scenarios-join-display-context.el new file mode 100644 index 00000000000..32b782d2af1 --- /dev/null +++ b/test/lisp/erc/erc-scenarios-join-display-context.el | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | ;;; erc-scenarios-join-display-context.el --- buffer-display autojoin ctx -*- lexical-binding: t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2023 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 19 | |||
| 20 | ;;; Commentary: | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'ert-x) | ||
| 25 | (eval-and-compile | ||
| 26 | (let ((load-path (cons (ert-resource-directory) load-path))) | ||
| 27 | (require 'erc-scenarios-common))) | ||
| 28 | |||
| 29 | (ert-deftest erc-scenarios-join-display-context--errors () | ||
| 30 | :tags '(:expensive-test) | ||
| 31 | (erc-scenarios-common-with-cleanup | ||
| 32 | ((erc-scenarios-common-dialog "join/buffer-display") | ||
| 33 | (erc-server-flood-penalty 0.1) | ||
| 34 | (dumb-server (erc-d-run "localhost" t 'mode-context)) | ||
| 35 | (port (process-contact dumb-server :service)) | ||
| 36 | (erc-buffer-display (lambda (buf action) | ||
| 37 | (when (equal | ||
| 38 | (alist-get 'erc-autojoin-mode action) | ||
| 39 | "#chan") | ||
| 40 | (pop-to-buffer buf)))) | ||
| 41 | (erc-autojoin-channels-alist '((foonet "#chan" "#spam" "#foo"))) | ||
| 42 | (expect (erc-d-t-make-expecter))) | ||
| 43 | |||
| 44 | (ert-info ("Connect without password") | ||
| 45 | (with-current-buffer (erc :server "127.0.0.1" | ||
| 46 | :port port | ||
| 47 | :nick "tester" | ||
| 48 | :full-name "tester") | ||
| 49 | (should (string= (buffer-name) (format "127.0.0.1:%d" port))) | ||
| 50 | ;; FIXME test for effect rather than inspecting interval variables. | ||
| 51 | (erc-d-t-wait-for 10 (equal erc-join--requested-channels | ||
| 52 | '("#foo" "#spam" "#chan"))) | ||
| 53 | (funcall expect 10 "Max occupancy for channel #spam exceeded") | ||
| 54 | (funcall expect 10 "Channel #foo is invitation only"))) | ||
| 55 | |||
| 56 | (ert-info ("New #chan buffer displayed in new window") | ||
| 57 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan")) | ||
| 58 | (should (eq (window-buffer) (current-buffer))) | ||
| 59 | (funcall expect 10 "#chan was created on"))) | ||
| 60 | |||
| 61 | ;; FIXME find a less dishonest way to do this than inspecting | ||
| 62 | ;; interval variables. | ||
| 63 | (ert-info ("Ensure channels no longer tracked") | ||
| 64 | (should-not erc-join--requested-channels)))) | ||
| 65 | |||
| 66 | ;;; erc-scenarios-join-display-context.el ends here | ||
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index fed25056b42..0e4ea1b1db6 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -427,8 +427,9 @@ | |||
| 427 | (should (looking-at-p (regexp-quote "*** Welcome")))) | 427 | (should (looking-at-p (regexp-quote "*** Welcome")))) |
| 428 | 428 | ||
| 429 | (ert-info ("Reconnect") | 429 | (ert-info ("Reconnect") |
| 430 | (erc-open "localhost" 6667 "tester" "Tester" nil | 430 | (with-current-buffer (erc-server-buffer) |
| 431 | "fake" nil "#chan" proc nil "user" nil) | 431 | (erc-open "localhost" 6667 "tester" "Tester" nil |
| 432 | "fake" nil "#chan" proc nil "user" nil)) | ||
| 432 | (should-not (get-buffer "#chan<2>"))) | 433 | (should-not (get-buffer "#chan<2>"))) |
| 433 | 434 | ||
| 434 | (ert-info ("Existing prompt respected") | 435 | (ert-info ("Existing prompt respected") |
| @@ -512,6 +513,50 @@ | |||
| 512 | (dolist (b '("server" "other" "#chan" "#foo" "#fake")) | 513 | (dolist (b '("server" "other" "#chan" "#foo" "#fake")) |
| 513 | (kill-buffer b)))) | 514 | (kill-buffer b)))) |
| 514 | 515 | ||
| 516 | (ert-deftest erc-setup-buffer--custom-action () | ||
| 517 | (erc-mode) | ||
| 518 | (erc-tests--set-fake-server-process "sleep" "1") | ||
| 519 | (setq erc--server-last-reconnect-count 0) | ||
| 520 | (let ((owin (selected-window)) | ||
| 521 | (obuf (window-buffer)) | ||
| 522 | (mbuf (messages-buffer)) | ||
| 523 | calls) | ||
| 524 | (cl-letf (((symbol-function 'switch-to-buffer) ; regression | ||
| 525 | (lambda (&rest r) (push (cons 'switch-to-buffer r) calls))) | ||
| 526 | ((symbol-function 'erc--test-fun) | ||
| 527 | (lambda (&rest r) (push (cons 'erc--test-fun r) calls))) | ||
| 528 | ((symbol-function 'display-buffer) | ||
| 529 | (lambda (&rest r) (push (cons 'display-buffer r) calls)))) | ||
| 530 | |||
| 531 | ;; Baseline | ||
| 532 | (let ((erc-join-buffer 'bury)) | ||
| 533 | (erc-setup-buffer mbuf) | ||
| 534 | (should-not calls)) | ||
| 535 | |||
| 536 | (should-not erc--display-context) | ||
| 537 | |||
| 538 | ;; `display-buffer' | ||
| 539 | (let ((erc--display-context '((erc-buffer-display . 1))) | ||
| 540 | (erc-join-buffer 'erc--test-fun)) | ||
| 541 | (erc-setup-buffer mbuf) | ||
| 542 | (should (equal `(erc--test-fun ,mbuf (nil (erc-buffer-display . 1))) | ||
| 543 | (pop calls))) | ||
| 544 | (should-not calls)) | ||
| 545 | |||
| 546 | ;; `pop-to-buffer' with `erc-auto-reconnect-display' | ||
| 547 | (let* ((erc--server-last-reconnect-count 1) | ||
| 548 | (erc--display-context '((erc-buffer-display . 1))) | ||
| 549 | (erc-auto-reconnect-display 'erc--test-fun)) | ||
| 550 | (erc-setup-buffer mbuf) | ||
| 551 | (should (equal `(erc--test-fun ,mbuf | ||
| 552 | (nil (erc-auto-reconnect-display . t) | ||
| 553 | (erc-buffer-display . 1))) | ||
| 554 | (pop calls))) | ||
| 555 | (should-not calls))) | ||
| 556 | |||
| 557 | (should (eq owin (selected-window))) | ||
| 558 | (should (eq obuf (window-buffer))))) | ||
| 559 | |||
| 515 | (ert-deftest erc-lurker-maybe-trim () | 560 | (ert-deftest erc-lurker-maybe-trim () |
| 516 | (let (erc-lurker-trim-nicks | 561 | (let (erc-lurker-trim-nicks |
| 517 | (erc-lurker-ignore-chars "_`")) | 562 | (erc-lurker-ignore-chars "_`")) |
| @@ -1537,14 +1582,18 @@ | |||
| 1537 | (erc-join-buffer . window)))))) | 1582 | (erc-join-buffer . window)))))) |
| 1538 | 1583 | ||
| 1539 | (ert-info ("Switches to TLS when URL is ircs://") | 1584 | (ert-info ("Switches to TLS when URL is ircs://") |
| 1540 | (should (equal (ert-simulate-keys "ircs://irc.gnu.org\r\r\r\r" | 1585 | (let ((erc--display-context '((erc-interactive-display . erc)))) |
| 1541 | (erc-select-read-args)) | 1586 | (should (equal (ert-simulate-keys "ircs://irc.gnu.org\r\r\r\r" |
| 1542 | (list :server "irc.gnu.org" | 1587 | (erc-select-read-args)) |
| 1543 | :port 6697 | 1588 | (list :server "irc.gnu.org" |
| 1544 | :nick (user-login-name) | 1589 | :port 6697 |
| 1545 | '&interactive-env | 1590 | :nick (user-login-name) |
| 1546 | '((erc-server-connect-function . erc-open-tls-stream) | 1591 | '&interactive-env |
| 1547 | (erc-join-buffer . window)))))) | 1592 | '((erc-server-connect-function |
| 1593 | . erc-open-tls-stream) | ||
| 1594 | (erc--display-context | ||
| 1595 | . ((erc-interactive-display . erc))) | ||
| 1596 | (erc-join-buffer . window))))))) | ||
| 1548 | 1597 | ||
| 1549 | (setq-local erc-interactive-display nil) ; cheat to save space | 1598 | (setq-local erc-interactive-display nil) ; cheat to save space |
| 1550 | 1599 | ||
| @@ -1624,6 +1673,7 @@ | |||
| 1624 | ((symbol-function 'erc-open) | 1673 | ((symbol-function 'erc-open) |
| 1625 | (lambda (&rest r) | 1674 | (lambda (&rest r) |
| 1626 | (push `((erc-join-buffer ,erc-join-buffer) | 1675 | (push `((erc-join-buffer ,erc-join-buffer) |
| 1676 | (erc--display-context ,@erc--display-context) | ||
| 1627 | (erc-server-connect-function | 1677 | (erc-server-connect-function |
| 1628 | ,erc-server-connect-function)) | 1678 | ,erc-server-connect-function)) |
| 1629 | env) | 1679 | env) |
| @@ -1636,6 +1686,7 @@ | |||
| 1636 | nil nil nil nil nil "user" nil))) | 1686 | nil nil nil nil nil "user" nil))) |
| 1637 | (should (equal (pop env) | 1687 | (should (equal (pop env) |
| 1638 | '((erc-join-buffer bury) | 1688 | '((erc-join-buffer bury) |
| 1689 | (erc--display-context (erc-buffer-display . erc-tls)) | ||
| 1639 | (erc-server-connect-function erc-open-tls-stream))))) | 1690 | (erc-server-connect-function erc-open-tls-stream))))) |
| 1640 | 1691 | ||
| 1641 | (ert-info ("Full") | 1692 | (ert-info ("Full") |
| @@ -1652,6 +1703,7 @@ | |||
| 1652 | "bob:changeme" nil nil nil t "bobo" GNU.org))) | 1703 | "bob:changeme" nil nil nil t "bobo" GNU.org))) |
| 1653 | (should (equal (pop env) | 1704 | (should (equal (pop env) |
| 1654 | '((erc-join-buffer bury) | 1705 | '((erc-join-buffer bury) |
| 1706 | (erc--display-context (erc-buffer-display . erc-tls)) | ||
| 1655 | (erc-server-connect-function erc-open-tls-stream))))) | 1707 | (erc-server-connect-function erc-open-tls-stream))))) |
| 1656 | 1708 | ||
| 1657 | ;; Values are often nil when called by lisp code, which leads to | 1709 | ;; Values are often nil when called by lisp code, which leads to |
| @@ -1671,6 +1723,7 @@ | |||
| 1671 | "bob:changeme" nil nil nil nil "bobo" nil))) | 1723 | "bob:changeme" nil nil nil nil "bobo" nil))) |
| 1672 | (should (equal (pop env) | 1724 | (should (equal (pop env) |
| 1673 | '((erc-join-buffer bury) | 1725 | '((erc-join-buffer bury) |
| 1726 | (erc--display-context (erc-buffer-display . erc-tls)) | ||
| 1674 | (erc-server-connect-function erc-open-tls-stream))))) | 1727 | (erc-server-connect-function erc-open-tls-stream))))) |
| 1675 | 1728 | ||
| 1676 | (ert-info ("Interactive") | 1729 | (ert-info ("Interactive") |
| @@ -1681,6 +1734,8 @@ | |||
| 1681 | nil nil nil nil "user" nil))) | 1734 | nil nil nil nil "user" nil))) |
| 1682 | (should (equal (pop env) | 1735 | (should (equal (pop env) |
| 1683 | '((erc-join-buffer window) | 1736 | '((erc-join-buffer window) |
| 1737 | (erc--display-context | ||
| 1738 | (erc-interactive-display . erc-tls)) | ||
| 1684 | (erc-server-connect-function erc-open-tls-stream))))) | 1739 | (erc-server-connect-function erc-open-tls-stream))))) |
| 1685 | 1740 | ||
| 1686 | (ert-info ("Custom connect function") | 1741 | (ert-info ("Custom connect function") |
| @@ -1691,6 +1746,8 @@ | |||
| 1691 | nil nil nil nil nil "user" nil))) | 1746 | nil nil nil nil nil "user" nil))) |
| 1692 | (should (equal (pop env) | 1747 | (should (equal (pop env) |
| 1693 | '((erc-join-buffer bury) | 1748 | '((erc-join-buffer bury) |
| 1749 | (erc--display-context | ||
| 1750 | (erc-buffer-display . erc-tls)) | ||
| 1694 | (erc-server-connect-function my-connect-func)))))) | 1751 | (erc-server-connect-function my-connect-func)))))) |
| 1695 | 1752 | ||
| 1696 | (ert-info ("Advised default function overlooked") ; intentional | 1753 | (ert-info ("Advised default function overlooked") ; intentional |
| @@ -1702,6 +1759,7 @@ | |||
| 1702 | nil nil nil nil nil "user" nil))) | 1759 | nil nil nil nil nil "user" nil))) |
| 1703 | (should (equal (pop env) | 1760 | (should (equal (pop env) |
| 1704 | '((erc-join-buffer bury) | 1761 | '((erc-join-buffer bury) |
| 1762 | (erc--display-context (erc-buffer-display . erc-tls)) | ||
| 1705 | (erc-server-connect-function erc-open-tls-stream)))) | 1763 | (erc-server-connect-function erc-open-tls-stream)))) |
| 1706 | (advice-remove 'erc-server-connect-function 'erc-tests--erc-tls)) | 1764 | (advice-remove 'erc-server-connect-function 'erc-tests--erc-tls)) |
| 1707 | 1765 | ||
| @@ -1715,6 +1773,8 @@ | |||
| 1715 | '("irc.libera.chat" 6697 "tester" "unknown" t | 1773 | '("irc.libera.chat" 6697 "tester" "unknown" t |
| 1716 | nil nil nil nil nil "user" nil))) | 1774 | nil nil nil nil nil "user" nil))) |
| 1717 | (should (equal (pop env) `((erc-join-buffer bury) | 1775 | (should (equal (pop env) `((erc-join-buffer bury) |
| 1776 | (erc--display-context | ||
| 1777 | (erc-buffer-display . erc-tls)) | ||
| 1718 | (erc-server-connect-function ,f)))) | 1778 | (erc-server-connect-function ,f)))) |
| 1719 | (advice-remove 'erc-server-connect-function | 1779 | (advice-remove 'erc-server-connect-function |
| 1720 | 'erc-tests--erc-tls))))))) | 1780 | 'erc-tests--erc-tls))))))) |
| @@ -1729,6 +1789,7 @@ | |||
| 1729 | ((symbol-function 'erc-open) | 1789 | ((symbol-function 'erc-open) |
| 1730 | (lambda (&rest r) | 1790 | (lambda (&rest r) |
| 1731 | (push `((erc-join-buffer ,erc-join-buffer) | 1791 | (push `((erc-join-buffer ,erc-join-buffer) |
| 1792 | (erc--display-context ,@erc--display-context) | ||
| 1732 | (erc-server-connect-function | 1793 | (erc-server-connect-function |
| 1733 | ,erc-server-connect-function)) | 1794 | ,erc-server-connect-function)) |
| 1734 | env) | 1795 | env) |
| @@ -1741,8 +1802,9 @@ | |||
| 1741 | '("irc.libera.chat" 6697 "tester" "unknown" t nil | 1802 | '("irc.libera.chat" 6697 "tester" "unknown" t nil |
| 1742 | nil nil nil nil "user" nil))) | 1803 | nil nil nil nil "user" nil))) |
| 1743 | (should (equal (pop env) | 1804 | (should (equal (pop env) |
| 1744 | '((erc-join-buffer window) (erc-server-connect-function | 1805 | '((erc-join-buffer window) |
| 1745 | erc-open-tls-stream))))) | 1806 | (erc--display-context (erc-interactive-display . erc)) |
| 1807 | (erc-server-connect-function erc-open-tls-stream))))) | ||
| 1746 | 1808 | ||
| 1747 | (ert-info ("Nick supplied, decline TLS upgrade") | 1809 | (ert-info ("Nick supplied, decline TLS upgrade") |
| 1748 | (ert-simulate-keys "\r\rdummy\r\rn\r" | 1810 | (ert-simulate-keys "\r\rdummy\r\rn\r" |
| @@ -1752,6 +1814,7 @@ | |||
| 1752 | nil nil nil nil "user" nil))) | 1814 | nil nil nil nil "user" nil))) |
| 1753 | (should (equal (pop env) | 1815 | (should (equal (pop env) |
| 1754 | '((erc-join-buffer window) | 1816 | '((erc-join-buffer window) |
| 1817 | (erc--display-context (erc-interactive-display . erc)) | ||
| 1755 | (erc-server-connect-function | 1818 | (erc-server-connect-function |
| 1756 | erc-open-network-stream)))))))) | 1819 | erc-open-network-stream)))))))) |
| 1757 | 1820 | ||
| @@ -1762,6 +1825,7 @@ | |||
| 1762 | ((symbol-function 'erc-open) | 1825 | ((symbol-function 'erc-open) |
| 1763 | (lambda (&rest r) | 1826 | (lambda (&rest r) |
| 1764 | (push `((erc-join-buffer ,erc-join-buffer) | 1827 | (push `((erc-join-buffer ,erc-join-buffer) |
| 1828 | (erc--display-context ,@erc--display-context) | ||
| 1765 | (erc-server-connect-function | 1829 | (erc-server-connect-function |
| 1766 | ,erc-server-connect-function)) | 1830 | ,erc-server-connect-function)) |
| 1767 | env) | 1831 | env) |
| @@ -1776,6 +1840,7 @@ | |||
| 1776 | nil nil nil nil "user" nil))) | 1840 | nil nil nil nil "user" nil))) |
| 1777 | (should (equal (pop env) | 1841 | (should (equal (pop env) |
| 1778 | '((erc-join-buffer window) | 1842 | '((erc-join-buffer window) |
| 1843 | (erc--display-context (erc-interactive-display . erc)) | ||
| 1779 | (erc-server-connect-function erc-open-tls-stream))))) | 1844 | (erc-server-connect-function erc-open-tls-stream))))) |
| 1780 | 1845 | ||
| 1781 | (ert-info ("Selects entry that doesn't support TLS") | 1846 | (ert-info ("Selects entry that doesn't support TLS") |
| @@ -1787,6 +1852,7 @@ | |||
| 1787 | nil nil nil nil "user" nil))) | 1852 | nil nil nil nil "user" nil))) |
| 1788 | (should (equal (pop env) | 1853 | (should (equal (pop env) |
| 1789 | '((erc-join-buffer window) | 1854 | '((erc-join-buffer window) |
| 1855 | (erc--display-context (erc-interactive-display . erc)) | ||
| 1790 | (erc-server-connect-function | 1856 | (erc-server-connect-function |
| 1791 | erc-open-network-stream)))))))) | 1857 | erc-open-network-stream)))))))) |
| 1792 | 1858 | ||
diff --git a/test/lisp/erc/resources/join/buffer-display/mode-context.eld b/test/lisp/erc/resources/join/buffer-display/mode-context.eld new file mode 100644 index 00000000000..6ebbdc7e824 --- /dev/null +++ b/test/lisp/erc/resources/join/buffer-display/mode-context.eld | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | ;; -*- mode: lisp-data; -*- | ||
| 2 | ((nick 1 "NICK tester")) | ||
| 3 | ((user 1 "USER user 0 * :tester") | ||
| 4 | (0.00 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester") | ||
| 5 | (0.01 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version ergo-v2.8.0") | ||
| 6 | (0.00 ":irc.foonet.org 003 tester :This server was created Tue, 24 May 2022 05:28:42 UTC") | ||
| 7 | (0.00 ":irc.foonet.org 004 tester irc.foonet.org ergo-v2.8.0 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv") | ||
| 8 | (0.00 ":irc.foonet.org 005 tester AWAYLEN=390 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server") | ||
| 9 | (0.01 ":irc.foonet.org 005 tester MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=foonet NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY WHOX :are supported by this server") | ||
| 10 | (0.01 ":irc.foonet.org 005 tester draft/CHATHISTORY=100 :are supported by this server") | ||
| 11 | (0.00 ":irc.foonet.org 251 tester :There are 0 users and 4 invisible on 1 server(s)") | ||
| 12 | (0.00 ":irc.foonet.org 252 tester 0 :IRC Operators online") | ||
| 13 | (0.00 ":irc.foonet.org 253 tester 0 :unregistered connections") | ||
| 14 | (0.00 ":irc.foonet.org 254 tester 2 :channels formed") | ||
| 15 | (0.00 ":irc.foonet.org 255 tester :I have 4 clients and 0 servers") | ||
| 16 | (0.00 ":irc.foonet.org 265 tester 4 4 :Current local users 4, max 4") | ||
| 17 | (0.00 ":irc.foonet.org 266 tester 4 4 :Current global users 4, max 4") | ||
| 18 | (0.00 ":irc.foonet.org 422 tester :MOTD File is missing")) | ||
| 19 | |||
| 20 | ((mode 6 "MODE tester +i") | ||
| 21 | (0.00 ":irc.foonet.org 221 tester +i") | ||
| 22 | (0.00 ":irc.foonet.org NOTICE tester :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect.") | ||
| 23 | (0.02 ":irc.foonet.org 221 tester +i")) | ||
| 24 | |||
| 25 | ((join-chan 10 "JOIN #chan") | ||
| 26 | (0.03 ":tester!~u@w9rfqveugz722.irc JOIN #chan")) | ||
| 27 | |||
| 28 | ((~mode-chan 10 "MODE #chan") | ||
| 29 | (0.01 ":irc.foonet.org 353 tester = #chan :@tester") | ||
| 30 | (0.00 ":irc.foonet.org 366 tester #chan :End of NAMES list") | ||
| 31 | (0.01 ":irc.foonet.org 324 tester #chan +nt") | ||
| 32 | (0.03 ":irc.foonet.org 329 tester #chan 1653370308")) | ||
| 33 | |||
| 34 | ((~join-spam 10 "JOIN #spam") | ||
| 35 | (0.03 ":irc.foonet.org 471 tester #spam :Cannot join channel (+l)")) | ||
| 36 | |||
| 37 | ((~join-foo 10 "JOIN #foo") | ||
| 38 | (0.03 ":irc.foonet.org 473 tester #foo :Cannot join channel (+i)")) | ||