diff options
| author | F. Jason Park | 2023-10-15 13:20:07 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-10-20 15:24:06 -0700 |
| commit | f109396fe362d3bc556efe2a7315169c74724d63 (patch) | |
| tree | 6ee93a4db6f7d0491456209925ee0f23aa6c77af /test | |
| parent | 8cf66ab1e5ff253d72368901490f073634e1ae4b (diff) | |
| download | emacs-f109396fe362d3bc556efe2a7315169c74724d63.tar.gz emacs-f109396fe362d3bc556efe2a7315169c74724d63.zip | |
Prefer erc-target to erc-default-target
* etc/ERC-NEWS: Mention `erc-target' and new `erc-server-buffer-p'
alias.
* lisp/erc/erc-backend.el (erc-process-sentinel): Set `joined-p' slot
of `erc--target-channel' object to nil when applicable.
(erc-server-JOIN): Mark `erc--target-channel' object as being joined.
* lisp/erc/erc-common.el (erc--target-channel): Add `joined-p' slot.
Use hyphenated name so accessor function's name ends in "joined-p"
rather than "joinedp". Note that this will always be nil when
disconnected.
(erc--target): Relocate here from erc.el.
(erc-target): New public API function to return the current buffer's
target as a string, even in channels that have been unjoined.
* lisp/erc/erc-networks.el (erc--default-target): Remove forward
declaration.
(erc-networks--id-reload): Use `erc-target' instead of
`erc--default-target' as predicate for visiting target buffers.
* lisp/erc/erc.el (erc-remove-channel-users): Set channel "joinedness"
to nil in `erc--target-channel' object, when applicable.
(erc--target): Move to erc-common.
(erc--default-target): Remove, replaced by new function `erc-target'.
(erc-query-buffer-p): Use `erc-target'.
(erc-after-connect): Revise doc string.
(erc-connection-established): Revise doc string and move
`erc-unhide-query-prompt' business before hook.
(erc--current-buffer-joined-p): Remove comment and use new `joined-p'
slot of `erc--target-channel' for determining "joinedness" of channel.
(erc-kill-buffer-function): Use `erc--target-channel-p' for detecting
whether the buffer is a channel buffer.
* test/lisp/erc/erc-networks-tests.el
(erc-networks--shrink-ids-and-buffer-names--hook-collapse-target):
Remove comment.
* test/lisp/erc/erc-scenarios-base-reuse-buffers.el
(erc-scenarios-common--base-reuse-buffers-channel-buffers):
Clarify assertion.
* test/lisp/erc/erc-tests.el (erc-with-all-buffers-of-server):
Replace `erc-default-recipients' with `erc--target'.
(erc--target-from-string): Update expected shape of
`erc--target-channel' struct with new `joined-p' slot.
(erc-message): Set `erc--target' in buffer "#chan". (Bug#66578)
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-networks-tests.el | 5 | ||||
| -rw-r--r-- | test/lisp/erc/erc-scenarios-base-reuse-buffers.el | 2 | ||||
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 19 |
3 files changed, 11 insertions, 15 deletions
diff --git a/test/lisp/erc/erc-networks-tests.el b/test/lisp/erc/erc-networks-tests.el index 45ef0d10a6e..d0f1dddf6b3 100644 --- a/test/lisp/erc/erc-networks-tests.el +++ b/test/lisp/erc/erc-networks-tests.el | |||
| @@ -623,11 +623,6 @@ | |||
| 623 | :symbol 'foonet/dummy | 623 | :symbol 'foonet/dummy |
| 624 | :parts [foonet "dummy"] | 624 | :parts [foonet "dummy"] |
| 625 | :len 2) | 625 | :len 2) |
| 626 | ;; `erc-kill-buffer-function' uses legacy target detection | ||
| 627 | ;; but falls back on buffer name, so no need for: | ||
| 628 | ;; | ||
| 629 | ;; erc-default-recipients '("#a") | ||
| 630 | ;; | ||
| 631 | erc--target (erc--target-from-string "#a") | 626 | erc--target (erc--target-from-string "#a") |
| 632 | erc-server-process (with-temp-buffer | 627 | erc-server-process (with-temp-buffer |
| 633 | (erc-networks-tests--create-dead-proc))) | 628 | (erc-networks-tests--create-dead-proc))) |
diff --git a/test/lisp/erc/erc-scenarios-base-reuse-buffers.el b/test/lisp/erc/erc-scenarios-base-reuse-buffers.el index 71027a0c138..af483bb1a52 100644 --- a/test/lisp/erc/erc-scenarios-base-reuse-buffers.el +++ b/test/lisp/erc/erc-scenarios-base-reuse-buffers.el | |||
| @@ -124,6 +124,7 @@ Adapted from scenario clash-of-chans/uniquify described in Bug#48598: | |||
| 124 | (erc-d-t-search-for 1 "shake my sword") | 124 | (erc-d-t-search-for 1 "shake my sword") |
| 125 | (erc-cmd-PART "#chan") | 125 | (erc-cmd-PART "#chan") |
| 126 | (funcall expect 3 "You have left channel #chan") | 126 | (funcall expect 3 "You have left channel #chan") |
| 127 | (should-not (erc-get-channel-user (erc-current-nick))) | ||
| 127 | (erc-cmd-JOIN "#chan"))) | 128 | (erc-cmd-JOIN "#chan"))) |
| 128 | 129 | ||
| 129 | (ert-info ("Part #chan@barnet") | 130 | (ert-info ("Part #chan@barnet") |
| @@ -139,6 +140,7 @@ Adapted from scenario clash-of-chans/uniquify described in Bug#48598: | |||
| 139 | (get-buffer "#chan/127.0.0.1<3>")) | 140 | (get-buffer "#chan/127.0.0.1<3>")) |
| 140 | 141 | ||
| 141 | (ert-info ("Activity continues in new, <n>-suffixed #chan@foonet buffer") | 142 | (ert-info ("Activity continues in new, <n>-suffixed #chan@foonet buffer") |
| 143 | ;; The first /JOIN did not cause the same buffer to be reused. | ||
| 142 | (with-current-buffer "#chan/127.0.0.1" | 144 | (with-current-buffer "#chan/127.0.0.1" |
| 143 | (should-not (erc-get-channel-user (erc-current-nick)))) | 145 | (should-not (erc-get-channel-user (erc-current-nick)))) |
| 144 | (with-current-buffer "#chan/127.0.0.1<3>" | 146 | (with-current-buffer "#chan/127.0.0.1<3>" |
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 02dfc55b6d5..4d2f880b46f 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -69,26 +69,25 @@ | |||
| 69 | (with-current-buffer (get-buffer-create "#foo") | 69 | (with-current-buffer (get-buffer-create "#foo") |
| 70 | (erc-mode) | 70 | (erc-mode) |
| 71 | (setq erc-server-process proc-exnet) | 71 | (setq erc-server-process proc-exnet) |
| 72 | (setq erc-default-recipients '("#foo"))) | 72 | (setq erc--target (erc--target-from-string "#foo"))) |
| 73 | 73 | ||
| 74 | (with-current-buffer (get-buffer-create "#spam") | 74 | (with-current-buffer (get-buffer-create "#spam") |
| 75 | (erc-mode) | 75 | (erc-mode) |
| 76 | (setq erc-server-process proc-onet) | 76 | (setq erc-server-process proc-onet) |
| 77 | (setq erc-default-recipients '("#spam"))) | 77 | (setq erc--target (erc--target-from-string "#spam"))) |
| 78 | 78 | ||
| 79 | (with-current-buffer (get-buffer-create "#bar") | 79 | (with-current-buffer (get-buffer-create "#bar") |
| 80 | (erc-mode) | 80 | (erc-mode) |
| 81 | (setq erc-server-process proc-onet) | 81 | (setq erc-server-process proc-onet) |
| 82 | (setq erc-default-recipients '("#bar"))) | 82 | (setq erc--target (erc--target-from-string "#bar"))) |
| 83 | 83 | ||
| 84 | (with-current-buffer (get-buffer-create "#baz") | 84 | (with-current-buffer (get-buffer-create "#baz") |
| 85 | (erc-mode) | 85 | (erc-mode) |
| 86 | (setq erc-server-process proc-exnet) | 86 | (setq erc-server-process proc-exnet) |
| 87 | (setq erc-default-recipients '("#baz"))) | 87 | (setq erc--target (erc--target-from-string "#baz"))) |
| 88 | 88 | ||
| 89 | (should (eq (get-buffer-process "ExampleNet") proc-exnet)) | 89 | (should (eq (get-buffer-process "ExampleNet") proc-exnet)) |
| 90 | (erc-with-all-buffers-of-server (get-buffer-process "ExampleNet") | 90 | (erc-with-all-buffers-of-server (get-buffer-process "ExampleNet") nil |
| 91 | nil | ||
| 92 | (kill-buffer)) | 91 | (kill-buffer)) |
| 93 | 92 | ||
| 94 | (should-not (get-buffer "ExampleNet")) | 93 | (should-not (get-buffer "ExampleNet")) |
| @@ -102,8 +101,7 @@ | |||
| 102 | (calls 0) | 101 | (calls 0) |
| 103 | (get-test (lambda () (cl-incf calls) test))) | 102 | (get-test (lambda () (cl-incf calls) test))) |
| 104 | 103 | ||
| 105 | (erc-with-all-buffers-of-server proc-onet | 104 | (erc-with-all-buffers-of-server proc-onet (funcall get-test) |
| 106 | (funcall get-test) | ||
| 107 | (kill-buffer)) | 105 | (kill-buffer)) |
| 108 | 106 | ||
| 109 | (should (= calls 1))) | 107 | (should (= calls 1))) |
| @@ -812,7 +810,7 @@ | |||
| 812 | 810 | ||
| 813 | (ert-deftest erc--target-from-string () | 811 | (ert-deftest erc--target-from-string () |
| 814 | (should (equal (erc--target-from-string "#chan") | 812 | (should (equal (erc--target-from-string "#chan") |
| 815 | #s(erc--target-channel "#chan" \#chan))) | 813 | #s(erc--target-channel "#chan" \#chan nil))) |
| 816 | 814 | ||
| 817 | (should (equal (erc--target-from-string "Bob") | 815 | (should (equal (erc--target-from-string "Bob") |
| 818 | #s(erc--target "Bob" bob))) | 816 | #s(erc--target "Bob" bob))) |
| @@ -820,7 +818,7 @@ | |||
| 820 | (let ((erc--isupport-params (make-hash-table))) | 818 | (let ((erc--isupport-params (make-hash-table))) |
| 821 | (puthash 'CHANTYPES '("&#") erc--isupport-params) | 819 | (puthash 'CHANTYPES '("&#") erc--isupport-params) |
| 822 | (should (equal (erc--target-from-string "&Bitlbee") | 820 | (should (equal (erc--target-from-string "&Bitlbee") |
| 823 | #s(erc--target-channel-local "&Bitlbee" &bitlbee))))) | 821 | #s(erc--target-channel-local "&Bitlbee" &bitlbee nil))))) |
| 824 | 822 | ||
| 825 | (ert-deftest erc--modify-local-map () | 823 | (ert-deftest erc--modify-local-map () |
| 826 | (when (and (bound-and-true-p erc-irccontrols-mode) | 824 | (when (and (bound-and-true-p erc-irccontrols-mode) |
| @@ -1846,6 +1844,7 @@ | |||
| 1846 | (erc-mode) | 1844 | (erc-mode) |
| 1847 | (setq erc-server-process (buffer-local-value 'erc-server-process | 1845 | (setq erc-server-process (buffer-local-value 'erc-server-process |
| 1848 | (get-buffer "ExampleNet")) | 1846 | (get-buffer "ExampleNet")) |
| 1847 | erc--target (erc--target-from-string "#chan") | ||
| 1849 | erc-default-recipients '("#chan") | 1848 | erc-default-recipients '("#chan") |
| 1850 | erc-channel-users (make-hash-table :test 'equal) | 1849 | erc-channel-users (make-hash-table :test 'equal) |
| 1851 | erc-network 'ExampleNet) | 1850 | erc-network 'ExampleNet) |