emacs-diffs
[Top][All Lists]
Advanced

[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))))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]