[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ba7fe88b782 22/37: Optionally prompt for more ERC entry-point par
From: |
F. Jason Park |
Subject: |
master ba7fe88b782 22/37: Optionally prompt for more ERC entry-point params |
Date: |
Sat, 8 Apr 2023 17:31:31 -0400 (EDT) |
branch: master
commit ba7fe88b782ad516b4cbb5e99fb108f57a9235e2
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
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.)
---
doc/misc/erc.texi | 2 +-
lisp/erc/erc-compat.el | 3 ++-
lisp/erc/erc.el | 28 +++++++++++++++++++++-------
test/lisp/erc/erc-tests.el | 13 ++++++++++++-
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
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-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 @@
;;; Code:
(require 'compat nil 'noerror)
-(eval-when-compile (require 'cl-lib) (require 'url-parse))
+(eval-when-compile (require 'cl-lib))
;; Except for the "erc-" namespacing, these two definitions should be
;; continuously updated to match the latest upstream ones verbatim.
@@ -412,6 +412,7 @@ If START or END is negative, it counts from the end."
;;;; Misc 29.1
(defvar url-irc-function)
+(declare-function url-type "url-parse" (cl-x))
(defun erc-compat--29-browse-url-irc (string &rest _)
(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 @@
(require 'cl-lib)
(require 'format-spec)
(require 'auth-source)
-(eval-when-compile (require 'subr-x) (require 'url-parse))
+(eval-when-compile (require 'subr-x))
(defconst erc-version "5.6-git"
"This version of ERC.")
@@ -142,6 +142,12 @@
(declare-function word-at-point "thingatpt" (&optional no-properties))
(autoload 'word-at-point "thingatpt") ; for hl-nicks
+(declare-function url-host "url-parse" (cl-x))
+(declare-function url-password "url-parse" (cl-x))
+(declare-function url-portspec "url-parse" (cl-x))
+(declare-function url-type "url-parse" (cl-x))
+(declare-function url-user "url-parse" (cl-x))
+
;; tunable connection and authentication parameters
(defcustom erc-server nil
@@ -2257,8 +2263,8 @@ parameters SERVER and NICK."
;;;###autoload
(defun erc-select-read-args ()
- "Prompt the user for values of nick, server, port, and password."
- (require 'url-parse)
+ "Prompt the user for values of nick, server, port, and password.
+With prefix arg, also prompt for user and full name."
(let* ((input (let ((d (erc-compute-server)))
(read-string (format "Server or URL (default is %S): " d)
nil 'erc-server-history-list d)))
@@ -2278,6 +2284,14 @@ parameters SERVER and NICK."
(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 (erc-compute-user (url-user url))))
+ (read-string (format "User (default is %S): " d)
+ nil nil d))))
+ (full (and current-prefix-arg
+ (let ((d (erc-compute-full-name (url-user url))))
+ (read-string (format "Full name (default is %S): " d)
+ nil nil d))))
(passwd (let* ((p (with-suppressed-warnings ((obsolete erc-password))
(or (url-password url) erc-password)))
(m (if p
@@ -2298,8 +2312,8 @@ parameters SERVER and NICK."
(push `(erc-server-connect-function . ,opener) env))
(when (and passwd (string= "" passwd))
(setq passwd nil))
- `( :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))
,@(and env `(&interactive-env ,env)))))
(defmacro erc--with-entrypoint-environment (env &rest body)
@@ -2407,8 +2421,8 @@ Example usage:
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 beb4b4cef76..795864a2cc2 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1161,7 +1161,18 @@
(erc-select-read-args))
(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\r"
+ (let ((current-prefix-arg '(4)))
+ (erc-select-read-args)))
+ (list :server "localhost"
+ :port 6667
+ :nick "nick"
+ :user "nick"
+ :password "sesame"
+ :full-name "nick")))))
(ert-deftest erc-tls ()
(let (calls env)
- master cf83f9a0821 04/37: Fix DCC GET flag parsing in erc-dcc, (continued)
- master cf83f9a0821 04/37: Fix DCC GET flag parsing in erc-dcc, F. Jason Park, 2023/04/08
- master 52c8d5371e4 37/37: * etc/ERC-NEWS: Add section for ERC 5.6., F. Jason Park, 2023/04/08
- master 9c65ac73655 17/37: Warn when customizing minor-mode vars for ERC modules, F. Jason Park, 2023/04/08
- master 4b56739547c 32/37: Add erc-fill style based on visual-line-mode, F. Jason Park, 2023/04/08
- 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 <=
- 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, 2023/04/08
- 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