>From 6dd5bf870aec52b44080676301849c6d5059985a Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 29 Dec 2022 06:43:19 -0800 Subject: [PATCH 3/4] [POC] Display buffers differently for M-x erc * lisp/erc/erc.el (erc-buffer-display): Add alias for `erc-join-buffer'. (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'. --- lisp/erc/erc.el | 20 +++++++++++++++++++- test/lisp/erc/erc-tests.el | 14 +++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 86149f7d2f..049e8af350 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,18 @@ 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 "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. @@ -2203,7 +2216,8 @@ erc-select-read-args (setq port erc-default-port-tls)))) (setq opener #'erc-open-tls-stream)) `( :server ,server :port ,port :nick ,nick - ,@(and passwd `(:password ,passwd)) connect-function ,opener))) + ,@(and passwd `(:password ,passwd)) + buffer-display ,erc-interactive-display connect-function ,opener))) ;;;###autoload @@ -2215,6 +2229,8 @@ erc (full-name (erc-compute-full-name)) id ;; For interactive use + ((buffer-display erc-buffer-display) + erc-buffer-display) ((connect-function erc-server-connect-function) erc-server-connect-function)) "ERC is a powerful, modular, and extensible IRC client. @@ -2259,6 +2275,8 @@ erc-tls client-certificate id ;; For interactive use + ((buffer-display erc-buffer-display) + erc-buffer-display) ((connect-function erc-server-connect-function) #'erc-open-tls-stream)) "ERC is a powerful, modular, and extensible IRC client. diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index fb23aa3c0a..6d60c9e274 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 ("Opt out of non-TLS warning manually") @@ -1015,6 +1016,7 @@ erc-select-read-args (list :server "irc.libera.chat" :port 6667 :nick (user-login-name) + 'buffer-display 'buffer 'connect-function #'erc-open-network-stream)))) (ert-info ("Override non-TLS warning via URL scheme") @@ -1023,6 +1025,7 @@ erc-select-read-args (list :server "irc.libera.chat" :port 6667 :nick (user-login-name) + 'buffer-display 'buffer 'connect-function #'erc-open-network-stream)))) (ert-info ("Address includes port") @@ -1031,19 +1034,20 @@ erc-select-read-args (list :server "localhost" :port 6667 :nick "nick" + 'buffer-display 'buffer 'connect-function #'erc-open-network-stream)))) (ert-info ("Address includes nick, password skipped via option") (should (equal (ert-simulate-keys "nick@localhost:6667\r" (let (erc-prompt-for-password) - (butlast (erc-select-read-args) 2))) + (butlast (erc-select-read-args) 4))) (list :server "localhost" :port 6667 :nick "nick")))) (ert-info ("Address includes nick and password") (should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r" - (butlast (erc-select-read-args) 2)) + (butlast (erc-select-read-args) 4)) (list :server "localhost" :port 6667 :nick "nick" @@ -1051,21 +1055,21 @@ erc-select-read-args (ert-info ("IPv6 address plain") (should (equal (ert-simulate-keys "::1\r\r\r\r" - (butlast (erc-select-read-args) 2)) + (butlast (erc-select-read-args) 4)) (list :server "[::1]" :port 6667 :nick (user-login-name))))) (ert-info ("IPv6 address with port") (should (equal (ert-simulate-keys "[::1]:6667\r\r\r" - (butlast (erc-select-read-args) 2)) + (butlast (erc-select-read-args) 4)) (list :server "[::1]" :port 6667 :nick (user-login-name))))) (ert-info ("IPv6 address includes nick") (should (equal (ert-simulate-keys "nick@[::1]:6667\r\r" - (butlast (erc-select-read-args) 2)) + (butlast (erc-select-read-args) 4)) (list :server "[::1]" :port 6667 :nick "nick"))))) -- 2.38.1