From: F. Jason Park Date: Wed, 7 Sep 2022 02:09:54 +0000 (-0700) Subject: Bury new ERC buffers by default X-Git-Tag: emacs-29.0.90~1856^2~363 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=132d5cb0a3ec94afbb49772631861e00160ffffb;p=emacs.git 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) --- diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS index 075a677a9d9..988eb1e09c8 100644 --- a/etc/ERC-NEWS +++ b/etc/ERC-NEWS @@ -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 diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 2715121d3e8..20f22c896fe 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -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 diff --git a/test/lisp/erc/erc-scenarios-base-reconnect.el b/test/lisp/erc/erc-scenarios-base-reconnect.el index 30d692058d6..49298dc5942 100644 --- a/test/lisp/erc/erc-scenarios-base-reconnect.el +++ b/test/lisp/erc/erc-scenarios-base-reconnect.el @@ -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*") + (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 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")))))) + (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 () +(ert-deftest erc-scenarios-base-reconnect-options--default () :tags '(:expensive-test) - (should (eq erc-join-buffer 'buffer)) + (should (eq erc-join-buffer 'bury)) (should-not erc-reconnect-display) - (let ((erc-reconnect-display 'bury)) - (erc-scenarios-common--base-reconnect-options + (erc-scenarios-common--base-reconnect-options - (lambda () - (pop-to-buffer-same-window "*Messages*") + (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 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-ensure-for 3 "Channel #chan not shown" + (not (eq (window-buffer) (get-buffer "#chan")))) - (eq (window-buffer) (messages-buffer)))))) + (eq (window-buffer) (messages-buffer))))) ;; Upon reconnecting, playback for channel and target buffers is ;; routed correctly. Autojoin is irrelevant here, but for the