]> code.delx.au - gnu-emacs/blobdiff - lisp/erc/erc-join.el
* lisp/descr-text.el (describe-char-unicode-data): Fix copy/paste errors.
[gnu-emacs] / lisp / erc / erc-join.el
index ae7f90003a682d54add38d77862e689abe83166e..1fbafe008951a30c17a80dc18a784933154add07 100644 (file)
@@ -1,8 +1,9 @@
 ;;; erc-join.el --- autojoin channels on connect and reconnects
 
-;; Copyright (C) 2002-2004, 2006-2012 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2016 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <alex@gnu.org>
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: irc
 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcAutoJoin
 
@@ -33,7 +34,6 @@
 
 (require 'erc)
 (require 'auth-source)
-(eval-when-compile (require 'cl))
 
 (defgroup erc-autojoin nil
   "Enable autojoining."
@@ -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)
                               "")))))