[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix/bug-48598 b16a07dce1 03/27: Accept user keyword arg in ERC entry-poi
From: |
F. Jason Park |
Subject: |
fix/bug-48598 b16a07dce1 03/27: Accept user keyword arg in ERC entry-point commands |
Date: |
Fri, 8 Apr 2022 03:06:47 -0400 (EDT) |
branch: fix/bug-48598
commit b16a07dce1ec19659b06f31f556aa5665f08e2a4
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Accept user keyword arg in ERC entry-point commands
* lisp/erc/erc-backend.el (erc-server-reconnect): Reuse the username
argument from the previous session's USER command when reconnecting.
Also pass the existing client certificate, fixing an issue related to
bug#47788.
(erc-session-user-full-name): Move variable here from erc.el.
(erc-session-username): Add new local variable to store entry point
parameter.
* lisp/erc/erc.el (erc-session-user-full-name): Move variable to
erc-backend.
(erc-open, erc-determine-parameters, erc, erc-tls): Accept new
optional user parameter.
(erc--open-target): Preserve current `erc-session-username' when
calling `erc-open'.
(erc-login): Use `erc-session-username' instead of deriving it.
(erc-compute-user): Add new function to determine user name from
explicit argument or user options.
---
lisp/erc/erc-backend.el | 12 +++++++++++-
lisp/erc/erc.el | 34 ++++++++++++++++++++++------------
2 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index e656c9917c..84b498064b 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -123,6 +123,14 @@
"Nickname on the current server.
Use `erc-current-nick' to access this.")
+(defvar-local erc-session-user-full-name nil
+ "Real name used for the current session.
+Sent as the last argument to the USER command.")
+
+(defvar-local erc-session-username nil
+ "Username used for the current session.
+Sent as the first argument of the USER command.")
+
;;; Server attributes
(defvar-local erc-server-process nil
@@ -585,7 +593,9 @@ Make sure you are in an ERC buffer when running this."
(let ((erc-server-connect-function (or erc-session-connector
#'erc-open-network-stream)))
(erc-open erc-session-server erc-session-port erc-server-current-nick
- erc-session-user-full-name t erc-session-password)))))
+ erc-session-user-full-name t erc-session-password
+ nil nil nil erc-session-client-certificate
+ erc-session-username)))))
(defun erc-server-delayed-reconnect (buffer)
(if (buffer-live-p buffer)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index dd2849f79e..bf7ac4aa50 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -149,6 +149,8 @@
(defvar erc-session-connector)
(defvar erc-session-port)
(defvar erc-session-server)
+(defvar erc-session-user-full-name)
+(defvar erc-session-username)
;; tunable connection and authentication parameters
@@ -1820,9 +1822,6 @@ all channel buffers on all servers."
(defvar-local erc-default-recipients nil
"List of default recipients of the current buffer.")
-(defvar-local erc-session-user-full-name nil
- "Full name of the user on the current server.")
-
(defvar-local erc-channel-user-limit nil
"Limit of users per channel.")
@@ -1989,8 +1988,8 @@ removed from the list will be disabled."
(defun erc-open (&optional server port nick full-name
connect passwd tgt-list channel process
- client-certificate)
- "Connect to SERVER on PORT as NICK with FULL-NAME.
+ client-certificate user)
+ "Connect to SERVER on PORT as NICK with USER and FULL-NAME.
If CONNECT is non-nil, connect to the server. Otherwise assume
already connected and just create a separate buffer for the new
@@ -2095,7 +2094,7 @@ Returns the buffer for the given server or channel."
(erc-display-prompt)
(goto-char (point-max)))
- (erc-determine-parameters server port nick full-name)
+ (erc-determine-parameters server port nick full-name user)
;; Saving log file on exit
(run-hook-with-args 'erc-connect-pre-hook buffer)
@@ -2216,6 +2215,7 @@ parameters SERVER and NICK."
(cl-defun erc (&key (server (erc-compute-server))
(port (erc-compute-port))
(nick (erc-compute-nick))
+ (user (erc-compute-user))
password
(full-name (erc-compute-full-name)))
"ERC is a powerful, modular, and extensible IRC client.
@@ -2227,6 +2227,7 @@ Non-interactively, it takes the keyword arguments
(server (erc-compute-server))
(port (erc-compute-port))
(nick (erc-compute-nick))
+ (user (erc-compute-user))
password
(full-name (erc-compute-full-name))
@@ -2238,7 +2239,7 @@ then the server and full-name will be set to those values,
whereas `erc-compute-port' and `erc-compute-nick' will be invoked
for the values of the other parameters."
(interactive (erc-select-read-args))
- (erc-open server port nick full-name t password))
+ (erc-open server port nick full-name t password nil nil nil nil user))
;;;###autoload
(defalias 'erc-select #'erc)
@@ -2248,6 +2249,7 @@ for the values of the other parameters."
(cl-defun erc-tls (&key (server (erc-compute-server))
(port (erc-compute-port))
(nick (erc-compute-nick))
+ (user (erc-compute-user))
password
(full-name (erc-compute-full-name))
client-certificate)
@@ -2291,7 +2293,7 @@ Example usage:
(erc-select-read-args)))
(let ((erc-server-connect-function 'erc-open-tls-stream))
(erc-open server port nick full-name t password
- nil nil nil client-certificate)))
+ nil nil nil client-certificate user)))
(defun erc-open-tls-stream (name buffer host port &rest parameters)
"Open an TLS stream to an IRC server.
@@ -4321,7 +4323,8 @@ To change how this query window is displayed, use `let'
to bind
nil
(list target)
target
- erc-server-process)))
+ erc-server-process
+ erc-session-username)))
(unless buf
(error "Couldn't open query window"))
(erc-update-mode-line)
@@ -6163,14 +6166,14 @@ user input."
(erc-server-send
(format "USER %s %s %s :%s"
;; hacked - S.B.
- (if erc-anonymous-login erc-email-userid (user-login-name))
+ erc-session-username
"0" "*"
erc-session-user-full-name))
(erc-update-mode-line))
;; connection properties' heuristics
-(defun erc-determine-parameters (&optional server port nick name)
+(defun erc-determine-parameters (&optional server port nick name user)
"Determine the connection and authentication parameters.
Sets the buffer local variables:
@@ -6178,11 +6181,13 @@ Sets the buffer local variables:
- `erc-session-server'
- `erc-session-port'
- `erc-session-user-full-name'
+- `erc-session-username'
- `erc-server-current-nick'"
(setq erc-session-connector erc-server-connect-function
erc-session-server (erc-compute-server server)
erc-session-port (or port erc-default-port)
- erc-session-user-full-name (erc-compute-full-name name))
+ erc-session-user-full-name (erc-compute-full-name name)
+ erc-session-username (erc-compute-user user))
(erc-set-current-nick (erc-compute-nick nick)))
(defun erc-compute-server (&optional server)
@@ -6200,6 +6205,10 @@ non-nil value is found.
(getenv "IRCSERVER")
erc-default-server))
+(defun erc-compute-user (&optional user)
+ "Return a suitable value for the session user name."
+ (or user (if erc-anonymous-login erc-email-userid (user-login-name))))
+
(defun erc-compute-nick (&optional nick)
"Return user's IRC nick.
@@ -7028,6 +7037,7 @@ This function should be on `erc-kill-channel-hook'."
;; Teach url.el how to open irc:// URLs with ERC.
;; To activate, customize `url-irc-function' to `url-irc-erc'.
+;; FIXME change user to nick, and use API to find server buffer
;;;###autoload
(defun erc-handle-irc-url (host port channel user password)
"Use ERC to IRC on HOST:PORT in CHANNEL as USER with PASSWORD.
- branch fix/bug-48598 created (now ab2d93e564), F. Jason Park, 2022/04/08
- fix/bug-48598 b16a07dce1 03/27: Accept user keyword arg in ERC entry-point commands,
F. Jason Park <=
- fix/bug-48598 8b7760d301 07/27: Allow exemption from flood penalty in erc-backend, F. Jason Park, 2022/04/08
- fix/bug-48598 57eedf46ae 04/27: Add some ERC test helpers, F. Jason Park, 2022/04/08
- fix/bug-48598 911481d449 13/27: Add helper to determine local channels in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 eee86bc7d7 16/27: Add ERC test server and related resources, F. Jason Park, 2022/04/08
- fix/bug-48598 7cb4eec8a1 23/27: SQUASH-ME: Add ERC test scenarios for identity-aware autojoin, F. Jason Park, 2022/04/08
- fix/bug-48598 447bc23d7b 21/27: SQUASH-ME: Add ERC scenarios for identity-aware msg handlers, F. Jason Park, 2022/04/08
- fix/bug-48598 a999ff61fa 19/27: Register erc-kill-buffer-function locally, F. Jason Park, 2022/04/08
- fix/bug-48598 e0bf4383d7 24/27: Standardize auth-source queries in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 1978c3178c 10/27: Update ISUPPORT handling in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 6ee4329b46 02/27: Initialize erc-server-filter-data in erc-backend, F. Jason Park, 2022/04/08