aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2022-12-29 06:43:19 -0800
committerF. Jason Park2023-04-08 14:23:51 -0700
commitba7fe88b782ad516b4cbb5e99fb108f57a9235e2 (patch)
treee007fa2ce5bb1f6a8be089cd3713735c6556d5e3
parent3a012d1db24d613814296139c98324df1d7ef71f (diff)
downloademacs-ba7fe88b782ad516b4cbb5e99fb108f57a9235e2.tar.gz
emacs-ba7fe88b782ad516b4cbb5e99fb108f57a9235e2.zip
Optionally prompt for more ERC entry-point params
* doc/misc/erc.texi: Update statement about availability of `:user' keyword param when entry points called interactively. * lisp/erc/erc/compat.el: Don't require `url-parse' when compiling. Add forward declaration for `url-type'. * lisp/erc/erc.el: Don't require `url-parse' when compiling. Add forward declarations for accessors of `url' struct from `url-parse' library. (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. (Bug#60428.)
-rw-r--r--doc/misc/erc.texi2
-rw-r--r--lisp/erc/erc-compat.el3
-rw-r--r--lisp/erc/erc.el28
-rw-r--r--test/lisp/erc/erc-tests.el13
4 files changed, 36 insertions, 10 deletions
diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi
index b80affbc954..e92bf576e75 100644
--- a/doc/misc/erc.texi
+++ b/doc/misc/erc.texi
@@ -952,7 +952,7 @@ Here, ``password'' refers to your account password, which is usually
952your @samp{NickServ} password. To make this work, customize 952your @samp{NickServ} password. To make this work, customize
953@code{erc-sasl-user} and @code{erc-sasl-password} or specify the 953@code{erc-sasl-user} and @code{erc-sasl-password} or specify the
954@code{:user} and @code{:password} keyword arguments when invoking 954@code{:user} and @code{:password} keyword arguments when invoking
955@code{erc-tls}. Note that @code{:user} cannot be given interactively. 955@code{erc-tls}.
956 956
957@item @code{external} (via Client TLS Certificate) 957@item @code{external} (via Client TLS Certificate)
958This works in conjunction with the @code{:client-certificate} keyword 958This works in conjunction with the @code{:client-certificate} keyword
diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el
index 10a495211cc..29892b78a39 100644
--- a/lisp/erc/erc-compat.el
+++ b/lisp/erc/erc-compat.el
@@ -32,7 +32,7 @@
32;;; Code: 32;;; Code:
33 33
34(require 'compat nil 'noerror) 34(require 'compat nil 'noerror)
35(eval-when-compile (require 'cl-lib) (require 'url-parse)) 35(eval-when-compile (require 'cl-lib))
36 36
37;; Except for the "erc-" namespacing, these two definitions should be 37;; Except for the "erc-" namespacing, these two definitions should be
38;; continuously updated to match the latest upstream ones verbatim. 38;; continuously updated to match the latest upstream ones verbatim.
@@ -412,6 +412,7 @@ If START or END is negative, it counts from the end."
412;;;; Misc 29.1 412;;;; Misc 29.1
413 413
414(defvar url-irc-function) 414(defvar url-irc-function)
415(declare-function url-type "url-parse" (cl-x))
415 416
416(defun erc-compat--29-browse-url-irc (string &rest _) 417(defun erc-compat--29-browse-url-irc (string &rest _)
417 (require 'url-irc) 418 (require 'url-irc)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 4c856f49c04..85f0416f44b 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -65,7 +65,7 @@
65(require 'cl-lib) 65(require 'cl-lib)
66(require 'format-spec) 66(require 'format-spec)
67(require 'auth-source) 67(require 'auth-source)
68(eval-when-compile (require 'subr-x) (require 'url-parse)) 68(eval-when-compile (require 'subr-x))
69 69
70(defconst erc-version "5.6-git" 70(defconst erc-version "5.6-git"
71 "This version of ERC.") 71 "This version of ERC.")
@@ -142,6 +142,12 @@
142(declare-function word-at-point "thingatpt" (&optional no-properties)) 142(declare-function word-at-point "thingatpt" (&optional no-properties))
143(autoload 'word-at-point "thingatpt") ; for hl-nicks 143(autoload 'word-at-point "thingatpt") ; for hl-nicks
144 144
145(declare-function url-host "url-parse" (cl-x))
146(declare-function url-password "url-parse" (cl-x))
147(declare-function url-portspec "url-parse" (cl-x))
148(declare-function url-type "url-parse" (cl-x))
149(declare-function url-user "url-parse" (cl-x))
150
145;; tunable connection and authentication parameters 151;; tunable connection and authentication parameters
146 152
147(defcustom erc-server nil 153(defcustom erc-server nil
@@ -2257,8 +2263,8 @@ parameters SERVER and NICK."
2257 2263
2258;;;###autoload 2264;;;###autoload
2259(defun erc-select-read-args () 2265(defun erc-select-read-args ()
2260 "Prompt the user for values of nick, server, port, and password." 2266 "Prompt the user for values of nick, server, port, and password.
2261 (require 'url-parse) 2267With prefix arg, also prompt for user and full name."
2262 (let* ((input (let ((d (erc-compute-server))) 2268 (let* ((input (let ((d (erc-compute-server)))
2263 (read-string (format "Server or URL (default is %S): " d) 2269 (read-string (format "Server or URL (default is %S): " d)
2264 nil 'erc-server-history-list d))) 2270 nil 'erc-server-history-list d)))
@@ -2278,6 +2284,14 @@ parameters SERVER and NICK."
2278 (let ((d (erc-compute-nick))) 2284 (let ((d (erc-compute-nick)))
2279 (read-string (format "Nickname (default is %S): " d) 2285 (read-string (format "Nickname (default is %S): " d)
2280 nil 'erc-nick-history-list d)))) 2286 nil 'erc-nick-history-list d))))
2287 (user (and current-prefix-arg
2288 (let ((d (erc-compute-user (url-user url))))
2289 (read-string (format "User (default is %S): " d)
2290 nil nil d))))
2291 (full (and current-prefix-arg
2292 (let ((d (erc-compute-full-name (url-user url))))
2293 (read-string (format "Full name (default is %S): " d)
2294 nil nil d))))
2281 (passwd (let* ((p (with-suppressed-warnings ((obsolete erc-password)) 2295 (passwd (let* ((p (with-suppressed-warnings ((obsolete erc-password))
2282 (or (url-password url) erc-password))) 2296 (or (url-password url) erc-password)))
2283 (m (if p 2297 (m (if p
@@ -2298,8 +2312,8 @@ parameters SERVER and NICK."
2298 (push `(erc-server-connect-function . ,opener) env)) 2312 (push `(erc-server-connect-function . ,opener) env))
2299 (when (and passwd (string= "" passwd)) 2313 (when (and passwd (string= "" passwd))
2300 (setq passwd nil)) 2314 (setq passwd nil))
2301 `( :server ,server :port ,port :nick ,nick 2315 `( :server ,server :port ,port :nick ,nick ,@(and user `(:user ,user))
2302 ,@(and passwd `(:password ,passwd)) 2316 ,@(and passwd `(:password ,passwd)) ,@(and full `(:full-name ,full))
2303 ,@(and env `(&interactive-env ,env))))) 2317 ,@(and env `(&interactive-env ,env)))))
2304 2318
2305(defmacro erc--with-entrypoint-environment (env &rest body) 2319(defmacro erc--with-entrypoint-environment (env &rest body)
@@ -2407,8 +2421,8 @@ Example usage:
2407 2421
2408When present, ID should be a symbol or a string to use for naming 2422When present, ID should be a symbol or a string to use for naming
2409the server buffer and identifying the connection unequivocally. 2423the server buffer and identifying the connection unequivocally.
2410See Info node `(erc) Network Identifier' for details. Like USER 2424See Info node `(erc) Network Identifier' for details. Like
2411and CLIENT-CERTIFICATE, this parameter cannot be specified 2425CLIENT-CERTIFICATE, this parameter cannot be specified
2412interactively. 2426interactively.
2413 2427
2414\(fn &key SERVER PORT NICK USER PASSWORD FULL-NAME CLIENT-CERTIFICATE ID)" 2428\(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 beb4b4cef76..795864a2cc2 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1161,7 +1161,18 @@
1161 (erc-select-read-args)) 1161 (erc-select-read-args))
1162 (list :server "[::1]" 1162 (list :server "[::1]"
1163 :port 6667 1163 :port 6667
1164 :nick "nick"))))) 1164 :nick "nick"))))
1165
1166 (ert-info ("Extra args use URL nick by default")
1167 (should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r\r\r\r"
1168 (let ((current-prefix-arg '(4)))
1169 (erc-select-read-args)))
1170 (list :server "localhost"
1171 :port 6667
1172 :nick "nick"
1173 :user "nick"
1174 :password "sesame"
1175 :full-name "nick")))))
1165 1176
1166(ert-deftest erc-tls () 1177(ert-deftest erc-tls ()
1167 (let (calls env) 1178 (let (calls env)