]> code.delx.au - gnu-emacs/commitdiff
Don't join erc channels doubly
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 27 Dec 2015 19:25:57 +0000 (20:25 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 27 Dec 2015 19:26:22 +0000 (20:26 +0100)
* erc-join.el (erc-autojoin-channels): Don't join channels
more than once (if you have several nicks) (bug#20695).

lisp/erc/erc-join.el

index 4c99898bc413983555ccbaa24703d31954413ba6..c1ce14ab0162e41d2e27be6e3892268d03403aca 100644 (file)
@@ -156,7 +156,13 @@ This function is run from `erc-nickserv-identified-hook'."
     (dolist (l erc-autojoin-channels-alist)
       (when (string-match (car l) server)
        (dolist (chan (cdr l))
-         (erc-server-join-channel server chan)))))
+         (let ((buffer (erc-get-buffer chan)))
+           ;; Only auto-join the channels that we aren't already in
+           ;; using a different nick.
+           (when (or (not buffer)
+                     (not (with-current-buffer buffer
+                            (erc-server-process-alive))))
+             (erc-server-join-channel server chan)))))))
   ;; Return nil to avoid stomping on any other hook funcs.
   nil)
 
@@ -170,7 +176,7 @@ This function is run from `erc-nickserv-identified-hook'."
         (password (if (functionp secret)
                       (funcall secret)
                     secret)))
-    (erc-server-send (concat "join " channel
+    (erc-server-send (concat "JOIN " channel
                             (if password
                                 (concat " " password)
                               "")))))