From 5afc6f4d40af031258bcda8fe440448ce8a1aa01 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 29 Dec 2022 06:43:19 -0800 Subject: [PATCH 3/4] [5.6] Add display option for interactive ERC invocations * lisp/erc/erc.el (erc-buffer-display, erc-receive-query-display): Add aliases for `erc-join-buffer' and `erc-auto-query'. (erc-interactive-display): Add new option to control display of server buffers during interactive entry-point invocations. (erc-select-read-args): Pass `erc-interactive-display' to entry points. (erc, erc-tls): Add interactive-only to control initial buffer display. * test/lisp/erc/erc-tests.el (erc-select-read-args): Expect buffer-display values from `erc-interactive-display'. (Bug#60428.) --- lisp/erc/erc.el | 19 +++++++++++++++++++ test/lisp/erc/erc-tests.el | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 96866432ebd..09d55f60990 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1459,6 +1459,7 @@ erc-default-port-tls "IRC port to use for encrypted connections if it cannot be \ detected otherwise.") +(defvaralias 'erc-buffer-display 'erc-join-buffer) (defcustom erc-join-buffer 'bury "Determines how to display a newly created IRC buffer. @@ -1479,6 +1480,19 @@ erc-join-buffer (const :tag "Use current buffer" buffer) (const :tag "Use current buffer" t))) +(defcustom erc-interactive-display 'buffer + "How and whether to display server buffers for M-x erc. +See `erc-buffer-display' and friends for a description of +possible values." + :package-version '(ERC . "5.4.1") ; FIXME increment upon publishing to ELPA + :group 'erc-buffers + :type '(choice (const :tag "Use value of `erc-join-buffer'" nil) + (const :tag "Split window and select" window) + (const :tag "Split window, don't select" window-noselect) + (const :tag "New frame" frame) + (const :tag "Bury new and don't display existing" bury) + (const :tag "Use current buffer" buffer))) + (defcustom erc-reconnect-display nil "How (and whether) to display a channel buffer upon reconnecting. @@ -2201,6 +2215,8 @@ erc-select-read-args (setq passwd nil)) `( :server ,server :port ,port :nick ,nick ,@(and passwd `(:password ,passwd)) + ,@(and erc-interactive-display + `(buffer-display ,erc-interactive-display)) ,@(and opener `(connect-function ,opener))))) @@ -2213,6 +2229,7 @@ erc (full-name (erc-compute-full-name)) id ;; For interactive use + ((buffer-display erc-join-buffer) erc-join-buffer) ((connect-function erc-server-connect-function) erc-server-connect-function)) "ERC is a powerful, modular, and extensible IRC client. @@ -2257,6 +2274,7 @@ erc-tls client-certificate id ;; For interactive use + ((buffer-display erc-join-buffer) erc-join-buffer) ((connect-function erc-server-connect-function) (if (eq erc-server-connect-function #'erc-open-network-stream) @@ -4492,6 +4510,7 @@ erc-query (with-current-buffer server-buffer (erc--open-target target))) +(defvaralias 'erc-receive-query-display 'erc-auto-query) (defcustom erc-auto-query 'window-noselect "If non-nil, create a query buffer each time you receive a private message. If the buffer doesn't already exist, it is created. diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 10adc9d53a7..91cdf2f1770 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -1007,6 +1007,7 @@ erc-select-read-args (list :server "irc.libera.chat" :port 6697 :nick (user-login-name) + 'buffer-display 'buffer 'connect-function #'erc-open-tls-stream)))) (ert-info ("Switches to TLS when port matches default TLS port") @@ -1015,6 +1016,7 @@ erc-select-read-args (list :server "irc.gnu.org" :port 6697 :nick (user-login-name) + 'buffer-display 'buffer 'connect-function #'erc-open-tls-stream)))) (ert-info ("Switches to TLS when URL is ircs://") @@ -1023,8 +1025,11 @@ erc-select-read-args (list :server "irc.gnu.org" :port 6697 :nick (user-login-name) + 'buffer-display 'buffer 'connect-function #'erc-open-tls-stream)))) + (setq-local erc-interactive-display nil) ; cheat to save space + (ert-info ("Opt out of non-TLS warning manually") (should (equal (ert-simulate-keys "\r\r\r\rn\r" (erc-select-read-args)) -- 2.38.1