From f66f7b51ed099f911aefb26294c7b1524e973e37 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 14 Jun 2021 23:40:45 -0700 Subject: [PATCH] Don't set erc-server-announced-name unless known * lisp/erc/erc.el (erc-open): this function is called by the entry-point functions/commands `erc' and `erc-tls', as well as by query commands and join hooks to prepare a new/reused target buffer for an existing server process. In the case of the former, the variable erc-server-announced-name may be set in the current buffer when an entry point command is invoked. If that buffer is another server buffer in which the variable is already set, it's copied to the new server buffer when the dialed servers match. But there's no guarantee that the announced name will match when actually announced during an introductory burst. This also causes confusion in protocol logs and may make it more difficult to reproduce bugs. Setting it to nil helps ensure a consistent environment when setting up a buffer for all newly dialed server connections. --- lisp/erc/erc.el | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 73202016ba..fe57bc1998 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1991,11 +1991,7 @@ erc-open private key and the certificate. Returns the buffer for the given server or channel." - (let ((server-announced-name (when (and (boundp 'erc-session-server) - (string= server erc-session-server)) - erc-server-announced-name)) - (connected-p (unless connect erc-server-connected)) - (buffer (erc-get-buffer-create server port channel)) + (let ((buffer (erc-get-buffer-create server port channel)) (old-buffer (current-buffer)) old-point continued-session) @@ -2006,8 +2002,11 @@ erc-open (let ((old-recon-count erc-server-reconnect-count)) (erc-mode) (setq erc-server-reconnect-count old-recon-count)) - (setq erc-server-announced-name server-announced-name) - (setq erc-server-connected connected-p) + (unless connect + (setq erc-server-announced-name (with-current-buffer old-buffer + erc-server-announced-name)) + (setq erc-server-connected (with-current-buffer old-buffer + erc-server-connected))) ;; connection parameters (setq erc-server-process process) (setq erc-insert-marker (make-marker)) -- 2.31.1