From: F. Jason Park Date: Tue, 15 Jun 2021 06:40:45 +0000 (-0700) Subject: Don't set erc-server-announced-name unless known X-Git-Tag: emacs-29.0.90~1447^2~1335 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=de53d18a4d81e8b49d1dfecaf5481382a0ad8d08;p=emacs.git Don't set erc-server-announced-name unless known * lisp/erc/erc.el (erc-open): whenever this function is called, the variable `erc-server-announced-name' may be set locally in the calling server buffer. However, if that buffer's dialed server matches that of the one being created, the announced name is copied over on faith. But there's no guarantee that the name will match the one ultimately emitted by the server during its introductory burst. Beyond potentially causing confusion in protocol logs, this behavior may complicate debugging efforts. Setting the variable to nil helps ensure a consistent environment when preparing a buffer for all newly dialed connections. This commit also simplifies the setting of `erc-server-connected', which is always nil when connecting and vice-versa. --- diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 2ee461a6635..7f102dcefb1 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2047,11 +2047,7 @@ or t, which means that `auth-source' will be queried for the 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 (and erc-reuse-buffers erc--server-reconnecting))) @@ -2062,8 +2058,9 @@ Returns the buffer for the given server or channel." (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) + (when (setq erc-server-connected (not connect)) + (setq erc-server-announced-name + (buffer-local-value 'erc-server-announced-name old-buffer))) ;; connection parameters (setq erc-server-process process) (setq erc-insert-marker (make-marker))