[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3a012d1db24 21/37: Add display option for interactive ERC invocat
From: |
F. Jason Park |
Subject: |
master 3a012d1db24 21/37: Add display option for interactive ERC invocations |
Date: |
Sat, 8 Apr 2023 17:31:31 -0400 (EDT) |
branch: master
commit 3a012d1db24d613814296139c98324df1d7ef71f
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
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.
* test/lisp/erc/erc-tests.el (erc-select-read-args): Expect
buffer-display values from `erc-interactive-display'.
(erc-tls, erc--interactive): Also check `erc-join-buffer' in
environment when `erc-open' called. (Bug#60428.)
---
lisp/erc/erc.el | 17 ++++++++++++++++
test/lisp/erc/erc-tests.el | 50 +++++++++++++++++++++++++++++-----------------
2 files changed, 49 insertions(+), 18 deletions(-)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index e1abfee9ba3..4c856f49c04 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1501,6 +1501,7 @@ Defaults to the server buffer."
"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.
@@ -1521,6 +1522,19 @@ The available choices are:
(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.6") ; FIXME sync on release
+ :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.
@@ -2278,6 +2292,8 @@ parameters SERVER and NICK."
(setq port erc-default-port-tls)))
#'erc-open-tls-stream))
env)
+ (when erc-interactive-display
+ (push `(erc-join-buffer . ,erc-interactive-display) env))
(when opener
(push `(erc-server-connect-function . ,opener) env))
(when (and passwd (string= "" passwd))
@@ -4610,6 +4626,7 @@ To change how this query window is displayed, use `let'
to bind
(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 c5905ab4f67..beb4b4cef76 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1079,8 +1079,9 @@
(list :server "irc.libera.chat"
:port 6697
:nick (user-login-name)
- '&interactive-env '((erc-server-connect-function
- . erc-open-tls-stream))))))
+ '&interactive-env
+ '((erc-server-connect-function . erc-open-tls-stream)
+ (erc-join-buffer . buffer))))))
(ert-info ("Switches to TLS when port matches default TLS port")
(should (equal (ert-simulate-keys "irc.gnu.org\r6697\r\r\r"
@@ -1088,8 +1089,9 @@
(list :server "irc.gnu.org"
:port 6697
:nick (user-login-name)
- '&interactive-env '((erc-server-connect-function
- . erc-open-tls-stream))))))
+ '&interactive-env
+ '((erc-server-connect-function . erc-open-tls-stream)
+ (erc-join-buffer . buffer))))))
(ert-info ("Switches to TLS when URL is ircs://")
(should (equal (ert-simulate-keys "ircs://irc.gnu.org\r\r\r\r"
@@ -1097,8 +1099,11 @@
(list :server "irc.gnu.org"
:port 6697
:nick (user-login-name)
- '&interactive-env '((erc-server-connect-function
- . erc-open-tls-stream))))))
+ '&interactive-env
+ '((erc-server-connect-function . erc-open-tls-stream)
+ (erc-join-buffer . buffer))))))
+
+ (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"
@@ -1164,7 +1169,8 @@
(lambda (&optional _) "tester"))
((symbol-function 'erc-open)
(lambda (&rest r)
- (push `((erc-server-connect-function
+ (push `((erc-join-buffer ,erc-join-buffer)
+ (erc-server-connect-function
,erc-server-connect-function))
env)
(push r calls))))
@@ -1175,7 +1181,8 @@
'("irc.libera.chat" 6697 "tester" "unknown" t
nil nil nil nil nil "user" nil)))
(should (equal (pop env)
- '((erc-server-connect-function erc-open-tls-stream)))))
+ '((erc-join-buffer bury)
+ (erc-server-connect-function erc-open-tls-stream)))))
(ert-info ("Full")
(erc-tls :server "irc.gnu.org"
@@ -1190,7 +1197,8 @@
'("irc.gnu.org" 7000 "bob" "Bob's Name" t
"bob:changeme" nil nil nil t "bobo" GNU.org)))
(should (equal (pop env)
- '((erc-server-connect-function erc-open-tls-stream)))))
+ '((erc-join-buffer bury)
+ (erc-server-connect-function erc-open-tls-stream)))))
;; Values are often nil when called by lisp code, which leads to
;; null params. This is why `erc-open' recomputes almost
@@ -1208,7 +1216,8 @@
'(nil 7000 nil "Bob's Name" t
"bob:changeme" nil nil nil nil "bobo" nil)))
(should (equal (pop env)
- '((erc-server-connect-function erc-open-tls-stream)))))
+ '((erc-join-buffer bury)
+ (erc-server-connect-function erc-open-tls-stream)))))
(ert-info ("Interactive")
(ert-simulate-keys "nick:sesame@localhost:6667\r\r"
@@ -1217,8 +1226,8 @@
'("localhost" 6667 "nick" "unknown" t "sesame"
nil nil nil nil "user" nil)))
(should (equal (pop env)
- '((erc-server-connect-function
- erc-open-tls-stream)))))
+ '((erc-join-buffer buffer)
+ (erc-server-connect-function erc-open-tls-stream)))))
(ert-info ("Custom connect function")
(let ((erc-server-connect-function 'my-connect-func))
@@ -1227,7 +1236,8 @@
'("irc.libera.chat" 6697 "tester" "unknown" t
nil nil nil nil nil "user" nil)))
(should (equal (pop env)
- '((erc-server-connect-function my-connect-func))))))
+ '((erc-join-buffer bury)
+ (erc-server-connect-function my-connect-func))))))
(ert-info ("Advised default function overlooked") ; intentional
(advice-add 'erc-server-connect-function :around #'ignore
@@ -1237,7 +1247,8 @@
'("irc.libera.chat" 6697 "tester" "unknown" t
nil nil nil nil nil "user" nil)))
(should (equal (pop env)
- '((erc-server-connect-function erc-open-tls-stream))))
+ '((erc-join-buffer bury)
+ (erc-server-connect-function erc-open-tls-stream))))
(advice-remove 'erc-server-connect-function 'erc-tests--erc-tls))
(ert-info ("Advised non-default function honored")
@@ -1249,7 +1260,8 @@
(should (equal (pop calls)
'("irc.libera.chat" 6697 "tester" "unknown" t
nil nil nil nil nil "user" nil)))
- (should (equal (pop env) `((erc-server-connect-function ,f))))
+ (should (equal (pop env) `((erc-join-buffer bury)
+ (erc-server-connect-function ,f))))
(advice-remove 'erc-server-connect-function
'erc-tests--erc-tls)))))))
@@ -1262,7 +1274,8 @@
(lambda (&optional _) "tester"))
((symbol-function 'erc-open)
(lambda (&rest r)
- (push `((erc-server-connect-function
+ (push `((erc-join-buffer ,erc-join-buffer)
+ (erc-server-connect-function
,erc-server-connect-function))
env)
(push r calls))))
@@ -1274,7 +1287,8 @@
'("irc.libera.chat" 6697 "tester" "unknown" t nil
nil nil nil nil "user" nil)))
(should (equal (pop env)
- '((erc-server-connect-function erc-open-tls-stream)))))
+ '((erc-join-buffer buffer) (erc-server-connect-function
+ erc-open-tls-stream)))))
(ert-info ("Nick supplied, decline TLS upgrade")
(ert-simulate-keys "\r\rdummy\r\rn\r"
@@ -1283,7 +1297,7 @@
'("irc.libera.chat" 6667 "dummy" "unknown" t nil
nil nil nil nil "user" nil)))
(should (equal (pop env)
- '(
+ '((erc-join-buffer buffer)
(erc-server-connect-function
erc-open-network-stream))))))))
- master 05f6fdb9e78 24/37: Preserve ERC prompt and its bounding markers, (continued)
- master 05f6fdb9e78 24/37: Preserve ERC prompt and its bounding markers, F. Jason Park, 2023/04/08
- master 8c0c9826844 08/37: Add hook to regain nickname in ERC, F. Jason Park, 2023/04/08
- master 8dd209eea47 19/37: Ignore killed buffers when switching in erc-track, F. Jason Park, 2023/04/08
- master e7992d2adbc 23/37: Add option to show visual erc-keep-place indicator, F. Jason Park, 2023/04/08
- master 0f7fc5cfdf9 20/37: Be smarter about switching to TLS from M-x erc, F. Jason Park, 2023/04/08
- master ad3dc74e074 27/37: Expose insertion time as text prop in erc-stamp, F. Jason Park, 2023/04/08
- master ba7fe88b782 22/37: Optionally prompt for more ERC entry-point params, F. Jason Park, 2023/04/08
- master 39d4f32fc9b 18/37: Fill doc strings for ERC modules, F. Jason Park, 2023/04/08
- master 22104de5daa 14/37: Add missing colors to erc-irccontrols-mode, F. Jason Park, 2023/04/08
- master 0d3ccdbde44 16/37: Don't associate ERC modules with undefined groups, F. Jason Park, 2023/04/08
- master 3a012d1db24 21/37: Add display option for interactive ERC invocations,
F. Jason Park <=
- master dfaeeba97cc 01/37: Change ERC version to 5.6-git, F. Jason Park, 2023/04/08
- master 03eddc99242 07/37: Add probing erc-server-reconnect-function variant, F. Jason Park, 2023/04/08
- master b1007516cdf 02/37: Add subcommand dispatch facility to erc-cmd-HELP, F. Jason Park, 2023/04/08
- master 2d876a4ca94 15/37: Convert ERC's Imenu integration into proper module, F. Jason Park, 2023/04/08
- master 61ed0b43cdb 05/37: Split overlong outgoing messages in erc-sasl, F. Jason Park, 2023/04/08
- master 8184a815aff 34/37: Add erc-button helper for substituting command keys, F. Jason Park, 2023/04/08
- master 379d35695b1 28/37: Make some erc-stamp functions more limber, F. Jason Park, 2023/04/08
- master 1f1cd467c6a 33/37: Replace Info-goto-node with info in erc-button-alist, F. Jason Park, 2023/04/08
- master e69bd59ec59 09/37: Honor arbitrary CHANTYPES in ERC, F. Jason Park, 2023/04/08
- master d5435a0d822 25/37: Refactor marker initialization in erc-open, F. Jason Park, 2023/04/08