diff options
| author | F. Jason Park | 2023-04-10 17:58:05 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-05-05 17:18:01 -0700 |
| commit | 5de90fa9611ec796a0c459dbcd32a246ff76543c (patch) | |
| tree | 7045c7aed005bc0c2a0ac2e7bf0c71dbd4f335fe /test | |
| parent | 8654cea5843aa2fa2074f317d338451eadae092f (diff) | |
| download | emacs-5de90fa9611ec796a0c459dbcd32a246ff76543c.tar.gz emacs-5de90fa9611ec796a0c459dbcd32a246ff76543c.zip | |
Extend erc-interactive-display to cover /JOINs
* lisp/erc/erc.el (erc-display): Mention that buffer-related display
options live in the customization group `erc-buffers'.
(erc-buffer-display, erc-join-buffer): Swap alias and aliased so that
the favored name, `erc-buffer-display', appears in the definition and
in the Customize menu. Also note related buffer-display options in
the doc string.
(erc-query-display, erc-interactive-display): Make the former an alias
of the latter, new in ERC 5.6, because their roles were functionally
redundant and thus confusing. Inherit the default value from
`erc-query-display' because users are more familiar with the pop-up
window behavior than a single-window replacement.
(erc-reconnect-display): Use preferred name for cross-referencing
fallback option `erc-buffer-display' in doc string, and explain how
/reconnect handling differs.
(erc--setup-buffer-hook): Add new internal hook for modules that
operate on windows and frames, such as erc-speedbar and
erc-status-sidebar.
(erc-open): Run `erc--setup-buffer-hook' after `erc-setup-buffer' so
hook members know their code isn't tied to `erc-setup-buffer' itself,
which may be used in other contexts, but rather to a new ERC buffer on
which some display-related action has just been performed.
(erc--called-as-input-p): New variable for "slash" commands, like
`erc-cmd-FOO', to detect whether they're being called "interactively"
as a result of input given at ERC's prompt.
(erc-process-input-line): Bind `erc--called-as-input-p' when running
slash commands.
(erc-cmd-JOIN): When called interactively, schedule a callback to wrap
the response handler and control how new buffers are thus displayed.
(erc-cmd-QUERY): Use preferred alias for `erc-query-display'.
* test/lisp/erc/erc-scenarios-base-buffer-display.el:
(erc-scenarios-base-buffer-display--interactive-default): New test.
* test/lisp/erc/erc-tests.el (erc-process-input-line,
erc-select-read-args, erc-tls, erc--interactive): Change expected
default value of `erc-interactive-display' from `buffer' to
`window'. (Bug#62833)
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-scenarios-base-buffer-display.el | 37 | ||||
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 13 |
2 files changed, 44 insertions, 6 deletions
diff --git a/test/lisp/erc/erc-scenarios-base-buffer-display.el b/test/lisp/erc/erc-scenarios-base-buffer-display.el index d511c8ff738..3ed7a83653e 100644 --- a/test/lisp/erc/erc-scenarios-base-buffer-display.el +++ b/test/lisp/erc/erc-scenarios-base-buffer-display.el | |||
| @@ -118,4 +118,41 @@ | |||
| 118 | 118 | ||
| 119 | (should (eq (window-buffer) (messages-buffer)))))) | 119 | (should (eq (window-buffer) (messages-buffer)))))) |
| 120 | 120 | ||
| 121 | |||
| 122 | ;; This shows that the option `erc-interactive-display' overrides | ||
| 123 | ;; `erc-join-buffer' during cold opens and interactive /JOINs. | ||
| 124 | |||
| 125 | (ert-deftest erc-scenarios-base-buffer-display--interactive-default () | ||
| 126 | :tags '(:expensive-test) | ||
| 127 | (should (eq erc-join-buffer 'bury)) | ||
| 128 | (should (eq erc-interactive-display 'window)) | ||
| 129 | |||
| 130 | (erc-scenarios-common-with-cleanup | ||
| 131 | ((erc-scenarios-common-dialog "join/legacy") | ||
| 132 | (dumb-server (erc-d-run "localhost" t 'foonet)) | ||
| 133 | (port (process-contact dumb-server :service)) | ||
| 134 | (url (format "tester:changeme@127.0.0.1:%d\r\r" port)) | ||
| 135 | (expect (erc-d-t-make-expecter)) | ||
| 136 | (erc-server-flood-penalty 0.1) | ||
| 137 | (erc-server-auto-reconnect t) | ||
| 138 | (erc-user-full-name "tester")) | ||
| 139 | |||
| 140 | (ert-info ("Connect to foonet") | ||
| 141 | (with-current-buffer (let (inhibit-interaction) | ||
| 142 | (ert-simulate-keys url | ||
| 143 | (call-interactively #'erc))) | ||
| 144 | (should (string= (buffer-name) (format "127.0.0.1:%d" port))) | ||
| 145 | |||
| 146 | (erc-d-t-wait-for 10 "Server buffer shown" | ||
| 147 | (eq (window-buffer) (current-buffer))) | ||
| 148 | (funcall expect 10 "debug mode") | ||
| 149 | (erc-scenarios-common-say "/JOIN #chan"))) | ||
| 150 | |||
| 151 | (ert-info ("Wait for output in #chan") | ||
| 152 | (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#chan")) | ||
| 153 | (funcall expect 10 "welcome") | ||
| 154 | (erc-d-t-ensure-for 3 "Channel #chan shown" | ||
| 155 | (eq (window-buffer) (current-buffer))) | ||
| 156 | (funcall expect 10 "be prosperous"))))) | ||
| 157 | |||
| 121 | ;;; erc-scenarios-base-buffer-display.el ends here | 158 | ;;; erc-scenarios-base-buffer-display.el ends here |
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 29bda7e742d..88b9babf206 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -1292,6 +1292,7 @@ | |||
| 1292 | (cl-letf (((symbol-function 'erc-cmd-MSG) | 1292 | (cl-letf (((symbol-function 'erc-cmd-MSG) |
| 1293 | (lambda (line) | 1293 | (lambda (line) |
| 1294 | (push line calls) | 1294 | (push line calls) |
| 1295 | (should erc--called-as-input-p) | ||
| 1295 | (funcall orig-erc-cmd-MSG line))) | 1296 | (funcall orig-erc-cmd-MSG line))) |
| 1296 | ((symbol-function 'erc-server-buffer) | 1297 | ((symbol-function 'erc-server-buffer) |
| 1297 | (lambda () (current-buffer))) | 1298 | (lambda () (current-buffer))) |
| @@ -1469,7 +1470,7 @@ | |||
| 1469 | :nick (user-login-name) | 1470 | :nick (user-login-name) |
| 1470 | '&interactive-env | 1471 | '&interactive-env |
| 1471 | '((erc-server-connect-function . erc-open-tls-stream) | 1472 | '((erc-server-connect-function . erc-open-tls-stream) |
| 1472 | (erc-join-buffer . buffer)))))) | 1473 | (erc-join-buffer . window)))))) |
| 1473 | 1474 | ||
| 1474 | (ert-info ("Switches to TLS when port matches default TLS port") | 1475 | (ert-info ("Switches to TLS when port matches default TLS port") |
| 1475 | (should (equal (ert-simulate-keys "irc.gnu.org\r6697\r\r\r" | 1476 | (should (equal (ert-simulate-keys "irc.gnu.org\r6697\r\r\r" |
| @@ -1479,7 +1480,7 @@ | |||
| 1479 | :nick (user-login-name) | 1480 | :nick (user-login-name) |
| 1480 | '&interactive-env | 1481 | '&interactive-env |
| 1481 | '((erc-server-connect-function . erc-open-tls-stream) | 1482 | '((erc-server-connect-function . erc-open-tls-stream) |
| 1482 | (erc-join-buffer . buffer)))))) | 1483 | (erc-join-buffer . window)))))) |
| 1483 | 1484 | ||
| 1484 | (ert-info ("Switches to TLS when URL is ircs://") | 1485 | (ert-info ("Switches to TLS when URL is ircs://") |
| 1485 | (should (equal (ert-simulate-keys "ircs://irc.gnu.org\r\r\r\r" | 1486 | (should (equal (ert-simulate-keys "ircs://irc.gnu.org\r\r\r\r" |
| @@ -1489,7 +1490,7 @@ | |||
| 1489 | :nick (user-login-name) | 1490 | :nick (user-login-name) |
| 1490 | '&interactive-env | 1491 | '&interactive-env |
| 1491 | '((erc-server-connect-function . erc-open-tls-stream) | 1492 | '((erc-server-connect-function . erc-open-tls-stream) |
| 1492 | (erc-join-buffer . buffer)))))) | 1493 | (erc-join-buffer . window)))))) |
| 1493 | 1494 | ||
| 1494 | (setq-local erc-interactive-display nil) ; cheat to save space | 1495 | (setq-local erc-interactive-display nil) ; cheat to save space |
| 1495 | 1496 | ||
| @@ -1625,7 +1626,7 @@ | |||
| 1625 | '("localhost" 6667 "nick" "unknown" t "sesame" | 1626 | '("localhost" 6667 "nick" "unknown" t "sesame" |
| 1626 | nil nil nil nil "user" nil))) | 1627 | nil nil nil nil "user" nil))) |
| 1627 | (should (equal (pop env) | 1628 | (should (equal (pop env) |
| 1628 | '((erc-join-buffer buffer) | 1629 | '((erc-join-buffer window) |
| 1629 | (erc-server-connect-function erc-open-tls-stream))))) | 1630 | (erc-server-connect-function erc-open-tls-stream))))) |
| 1630 | 1631 | ||
| 1631 | (ert-info ("Custom connect function") | 1632 | (ert-info ("Custom connect function") |
| @@ -1686,7 +1687,7 @@ | |||
| 1686 | '("irc.libera.chat" 6697 "tester" "unknown" t nil | 1687 | '("irc.libera.chat" 6697 "tester" "unknown" t nil |
| 1687 | nil nil nil nil "user" nil))) | 1688 | nil nil nil nil "user" nil))) |
| 1688 | (should (equal (pop env) | 1689 | (should (equal (pop env) |
| 1689 | '((erc-join-buffer buffer) (erc-server-connect-function | 1690 | '((erc-join-buffer window) (erc-server-connect-function |
| 1690 | erc-open-tls-stream))))) | 1691 | erc-open-tls-stream))))) |
| 1691 | 1692 | ||
| 1692 | (ert-info ("Nick supplied, decline TLS upgrade") | 1693 | (ert-info ("Nick supplied, decline TLS upgrade") |
| @@ -1696,7 +1697,7 @@ | |||
| 1696 | '("irc.libera.chat" 6667 "dummy" "unknown" t nil | 1697 | '("irc.libera.chat" 6667 "dummy" "unknown" t nil |
| 1697 | nil nil nil nil "user" nil))) | 1698 | nil nil nil nil "user" nil))) |
| 1698 | (should (equal (pop env) | 1699 | (should (equal (pop env) |
| 1699 | '((erc-join-buffer buffer) | 1700 | '((erc-join-buffer window) |
| 1700 | (erc-server-connect-function | 1701 | (erc-server-connect-function |
| 1701 | erc-open-network-stream)))))))) | 1702 | erc-open-network-stream)))))))) |
| 1702 | 1703 | ||