Bury new ERC buffers by default

* lisp/erc/erc.el (erc-join-buffer): Change default value to `bury'.
(erc-setup-buffer): Make `window-noselect' behave more like its
description and abstain from ever replacing the current buffer.
* test/lisp/erc/erc-scenarios-base-reconnect.el
(erc-scenarios-common-base-reconnect-options): Update helper to handle
new default value for option `erc-join-buffer'.
(erc-scenarios-base-reconnect-options--buffer): Update and rename
function `erc-scenarios-base-reconnect-options--default'.
(erc-scenarios-base-reconnect-options--default): Update and rename
function `erc-scenarios-base-reconnect-options--bury'.
* etc/ERC-NEWS: Update existing display-buffers section for 5.5.
(Bug#51753)
This commit is contained in:
F. Jason Park 2022-09-06 19:09:54 -07:00
parent 01de334c78
commit 132d5cb0a3
3 changed files with 39 additions and 29 deletions

View file

@ -59,9 +59,17 @@ which, when present, becomes the first argument passed to the "USER"
IRC command. The traditional way of setting this globally, via
'erc-email-userid', is still honored.
** Additional display options for updated buffers.
Additional flexibility is now available for controlling the behavior
of newly created target buffers, especially during reconnection.
** Changes to display options for new ERC buffers.
The default value for the option 'erc-join-buffer', which determines
how new buffers are displayed, has been changed to 'bury' for security
reasons. Although the old value of 'buffer' is still accessible,
along with its original behavior, users wanting a safer alternative
can now opt for an improved 'window-noselect' instead. It still
offers the same pronounced visual cue when connecting and joining but
now avoids any hijacking of the active window as well.
Beyond this, additional flexibility is now available for controlling
the behavior of newly created target buffers during reconnection.
** Improved handling of multiline prompt input.
This means better detection and handling of intervening and trailing

View file

@ -1651,7 +1651,7 @@ Defaults to the server buffer."
"IRC port to use for encrypted connections if it cannot be \
detected otherwise.")
(defcustom erc-join-buffer 'buffer
(defcustom erc-join-buffer 'bury
"Determines how to display a newly created IRC buffer.
The available choices are:
@ -1662,6 +1662,7 @@ The available choices are:
`bury' - bury it in a new buffer,
`buffer' - in place of the current buffer,
any other value - in place of the current buffer."
:package-version '(ERC . "5.4.1") ; FIXME increment upon publishing to ELPA
:group 'erc-buffers
:type '(choice (const :tag "Split window and select" window)
(const :tag "Split window, don't select" window-noselect)
@ -2148,7 +2149,7 @@ removed from the list will be disabled."
(display-buffer buffer)
(switch-to-buffer-other-window buffer)))
('window-noselect
(display-buffer buffer))
(display-buffer buffer '(nil (inhibit-same-window . t))))
('bury
nil)
('frame

View file

@ -99,10 +99,11 @@
(funcall test)
;; A manual /JOIN command tells ERC we're done auto-reconnecting
(with-current-buffer "FooNet" (erc-cmd-JOIN "#spam"))
(erc-d-t-wait-for 5 "Channel #spam shown when autojoined"
(eq (window-buffer) (get-buffer "#spam")))
(erc-d-t-ensure-for 1 "Newly joined chan ignores `erc-reconnect-display'"
(not (eq (window-buffer) (get-buffer "#spam"))))
(ert-info ("Wait for auto reconnect")
(with-current-buffer erc-server-buffer
@ -114,43 +115,43 @@
(with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam"))
(funcall expect 10 "her elves come here anon")))))
(ert-deftest erc-scenarios-base-reconnect-options--default ()
(ert-deftest erc-scenarios-base-reconnect-options--buffer ()
:tags '(:expensive-test)
(should (eq erc-join-buffer 'buffer))
(should (eq erc-join-buffer 'bury))
(should-not erc-reconnect-display)
;; FooNet (the server buffer) is not switched to because it's
;; already current (but not shown) when `erc-open' is called. See
;; related conditional guard towards the end of that function.
(erc-scenarios-common--base-reconnect-options
(lambda ()
(pop-to-buffer-same-window "*Messages*")
(erc-d-t-ensure-for 1 "Server buffer not shown"
(not (eq (window-buffer) (get-buffer "FooNet"))))
(erc-d-t-wait-for 5 "Channel #chan shown when autojoined"
(eq (window-buffer) (get-buffer "#chan"))))))
(ert-deftest erc-scenarios-base-reconnect-options--bury ()
:tags '(:expensive-test)
(should (eq erc-join-buffer 'buffer))
(should-not erc-reconnect-display)
(let ((erc-reconnect-display 'bury))
(let ((erc-reconnect-display 'buffer))
(erc-scenarios-common--base-reconnect-options
(lambda ()
(pop-to-buffer-same-window "*Messages*")
(erc-d-t-ensure-for 1 "Server buffer not shown"
(not (eq (window-buffer) (get-buffer "FooNet"))))
(erc-d-t-ensure-for 3 "Channel #chan not shown"
(not (eq (window-buffer) (get-buffer "#chan"))))
(erc-d-t-wait-for 5 "Channel #chan shown when autojoined"
(eq (window-buffer) (get-buffer "#chan")))))))
(eq (window-buffer) (messages-buffer))))))
(ert-deftest erc-scenarios-base-reconnect-options--default ()
:tags '(:expensive-test)
(should (eq erc-join-buffer 'bury))
(should-not erc-reconnect-display)
(erc-scenarios-common--base-reconnect-options
(lambda ()
(pop-to-buffer-same-window "*Messages*")
(erc-d-t-ensure-for 1 "Server buffer not shown"
(not (eq (window-buffer) (get-buffer "FooNet"))))
(erc-d-t-ensure-for 3 "Channel #chan not shown"
(not (eq (window-buffer) (get-buffer "#chan"))))
(eq (window-buffer) (messages-buffer)))))
;; Upon reconnecting, playback for channel and target buffers is
;; routed correctly. Autojoin is irrelevant here, but for the