From: F. Jason Park <jp@neverwas.me>
Date: Sun, 18 Sep 2022 08:49:23 +0000 (-0700)
Subject: Call erc-login indirectly via new generic wrapper
X-Git-Tag: emacs-29.0.90~1556
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ae254a65cd6c0292865c449d639140f5d149f68e;p=emacs.git

Call erc-login indirectly via new generic wrapper

* lisp/erc/erc-backend (erc--register-connection): Add new internal
generic function that defers to `erc-login' by default.
(erc-process-sentinel, erc-server-connect): Call
`erc--register-connection' instead of `erc-login'.
---

diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 30b53dfd8ed..973616bc37e 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -643,6 +643,10 @@ The current buffer is given by BUFFER."
   (let ((p (plist-put parameters :nowait t)))
     (apply #'open-network-stream name buffer host service p)))
 
+(cl-defmethod erc--register-connection ()
+  "Perform opening IRC protocol exchange with server."
+  (erc-login))
+
 (defvar erc--server-connect-dumb-ipv6-regexp
   ;; Not for validation (gives false positives).
   (rx bot "[" (group (+ (any xdigit digit ":.")) (? "%" (+ alnum))) "]" eot))
@@ -697,7 +701,7 @@ TLS (see `erc-session-client-certificate' for more details)."
         ;; waiting for a non-blocking connect - keep the user informed
         (erc-display-message nil nil buffer "Opening connection..\n")
       (message "%s...done" msg)
-      (erc-login)) ))
+      (erc--register-connection))))
 
 (defun erc-server-reconnect ()
   "Reestablish the current IRC connection.
@@ -897,7 +901,7 @@ Conditionally try to reconnect and take appropriate action."
                   cproc (process-status cproc) event erc-server-quitting))
         (if (string-match "^open" event)
             ;; newly opened connection (no wait)
-            (erc-login)
+            (erc--register-connection)
           ;; assume event is 'failed
           (erc-with-all-buffers-of-server cproc nil
                                           (setq erc-server-connected nil))