>From 66575cffd38d576f93348b089ec77e1b6e1dad57 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 29 Dec 2022 06:43:19 -0800 Subject: [PATCH 4/4] [POC] Optionally prompt for more ERC entry-point params * doc/misc/erc.texi: Update statement about availability of user param when entry points called interactively. * lisp/erc/erc.el (erc-select-read-args): Allow optionally calling entry points with a prefix arg to access params `user' and `:full-name'. (erc-tls): Update doc string. * test/lisp/erc/erc-tests.el (erc-select-read-args): Add test for extra args. --- doc/misc/erc.texi | 2 +- lisp/erc/erc.el | 19 ++++++++++++++----- test/lisp/erc/erc-tests.el | 13 ++++++++++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi index 249b58c73d..2e3b635f5e 100644 --- a/doc/misc/erc.texi +++ b/doc/misc/erc.texi @@ -932,7 +932,7 @@ SASL your @samp{NickServ} password. To make this work, customize @code{erc-sasl-user} and @code{erc-sasl-password} or specify the @code{:user} and @code{:password} keyword arguments when invoking -@code{erc-tls}. Note that @code{:user} cannot be given interactively. +@code{erc-tls}. @item @code{external} (via Client TLS Certificate) This works in conjunction with the @code{:client-certificate} keyword diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 049e8af350..585fba079f 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2176,7 +2176,8 @@ erc--ensure-url ;;;###autoload (defun erc-select-read-args () - "Prompt the user for values of nick, server, port, and password." + "Prompt the user for values of nick, server, port, and password. +With prefix arg, also prompt for user and full name." (require 'url-parse) (let* ((input (let ((d (erc-compute-server))) (read-string (format "Server (default is %S): " d) @@ -2197,6 +2198,14 @@ erc-select-read-args (let ((d (erc-compute-nick))) (read-string (format "Nickname (default is %S): " d) nil 'erc-nick-history-list d)))) + (user (and current-prefix-arg + (let ((d (or (url-user url) (erc-compute-user)))) + (read-string (format "User (default is %S): " d) + nil nil d)))) + (full (and current-prefix-arg + (let ((d (or (url-user url) (erc-compute-full-name)))) + (read-string (format "Full name (default is %S): " d) + nil nil d)))) (passwd (or (url-password url) (let* ((p (with-suppressed-warnings @@ -2215,8 +2224,8 @@ erc-select-read-args (and (y-or-n-p "Connect using TLS instead? ") (setq port erc-default-port-tls)))) (setq opener #'erc-open-tls-stream)) - `( :server ,server :port ,port :nick ,nick - ,@(and passwd `(:password ,passwd)) + `( :server ,server :port ,port :nick ,nick ,@(and user `(:user ,user)) + ,@(and passwd `(:password ,passwd)) ,@(and full `(:full-name ,full)) buffer-display ,erc-interactive-display connect-function ,opener))) @@ -2320,8 +2329,8 @@ erc-tls When present, ID should be a symbol or a string to use for naming the server buffer and identifying the connection unequivocally. -See info node `(erc) Network Identifier' for details. Like USER -and CLIENT-CERTIFICATE, this parameter cannot be specified +See info node `(erc) Network Identifier' for details. Like +CLIENT-CERTIFICATE, this parameter cannot be specified interactively. \(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME CLIENT-CERTIFICATE ID)" diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 6d60c9e274..e3df32d773 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -1072,7 +1072,18 @@ erc-select-read-args (butlast (erc-select-read-args) 4)) (list :server "[::1]" :port 6667 - :nick "nick"))))) + :nick "nick")))) + + (ert-info ("Extra args use URL nick by default") + (should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r\r\r" + (let ((current-prefix-arg '(4))) + (butlast (erc-select-read-args) 4))) + (list :server "localhost" + :port 6667 + :nick "nick" + :user "nick" + :password "sesame" + :full-name "nick"))))) (ert-deftest erc-tls () (let (calls) -- 2.38.1