Subject: bug#32723: [PATCH] Fix erc-autojoin for same channel names on multiple servers

From: Martin Kletzander <[email-masked]>
Date: Wed, 12 Sep 2018 17:44:29 +0200

When auto-joining channel with the same name on
multiple channels the auto-join will go over the
list of channels and for each one it checks if
there is a buffer and alive server process.
However it does not check if the server process
matches the server being currently processed for
auto-joining.

This happens since commit "Don't join erc channels
doubly"

Fix it by checking if the currently processed
server matches the erc process name of the already
joined channel.

* lisp/erc/erc-join.el (erc-autojoin-channels):
Join channels with the same name on different
servers.

Copyright-paperwork-exempt: yes
---
 lisp/erc/erc-join.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el
index a6bf6518ea86..567a4cc27e19 100644
--- a/lisp/erc/erc-join.el
+++ b/lisp/erc/erc-join.el
@@ -161,6 +161,9 @@ This function is run from `erc-nickserv-identified-hook'."
 	      ;; Only auto-join the channels that we aren't already in
 	      ;; using a different nick.
 	      (when (or (not buffer)
+			;; If the same channel is joined on another
+			;; server the best-effort is to just join
+			(not (string-match (car l) (process-name erc-server-process)))
 			(not (with-current-buffer buffer
 			       (erc-server-process-alive))))
 		(erc-server-join-channel server chan))))))))
-- 
2.18.0