all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Tom Tromey <tom@tromey.com>
Cc: 25349@debbugs.gnu.org,
	Nikolay Kudryavtsev <nikolay.kudryavtsev@gmail.com>
Subject: bug#25349: 25.1.90; erc join -vs- passwords
Date: Fri, 06 Jan 2017 08:14:07 -0700	[thread overview]
Message-ID: <878tqodxvk.fsf@tromey.com> (raw)
In-Reply-To: <87tw9ddtid.fsf@tromey.com> (Tom Tromey's message of "Thu, 05 Jan 2017 15:36:10 -0700")

Tom> Well, it worked for an explicit /join, but didn't correctly autojoin.
Tom> I'll try to debug it some more.

erc-autojoin-channels was just using the server that was passed in, but
it should have been checking erc-session-server instead, like the other
code.

The appended works for me for both autojoin and explicit join.  I want
to check it in, but it would probably be good if someone more familiar
with ERC took a look at it.

Tom

diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el
index 151ea15..aa83ffe 100644
--- a/lisp/erc/erc-join.el
+++ b/lisp/erc/erc-join.el
@@ -129,7 +129,7 @@ erc-autojoin-after-ident
       (setq erc--autojoin-timer
 	    (erc-cancel-timer erc--autojoin-timer)))
   (when (eq erc-autojoin-timing 'ident)
-    (let ((server (or erc-server-announced-name erc-session-server))
+    (let ((server (or erc-session-server erc-server-announced-name))
 	  (joined (mapcar (lambda (buf)
 			    (with-current-buffer buf (erc-default-target)))
 			  (erc-channel-list erc-server-process))))
@@ -155,38 +155,24 @@ erc-autojoin-channels
     ;; `erc-autojoin-timing' is `connect':
     (dolist (l erc-autojoin-channels-alist)
       (when (string-match (car l) server)
-	(dolist (chan (cdr l))
-	  (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)))))))
+	(let ((server (or erc-session-server erc-server-announced-name)))
+	  (dolist (chan (cdr l))
+	    (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)
 
-(defun erc-server-join-channel (server channel)
-  (let* ((secret (plist-get (nth 0 (auth-source-search
-				    :max 1
-				    :host server
-				    :port "irc"
-				    :user channel))
-			    :secret))
-	 (password (if (functionp secret)
-		       (funcall secret)
-		     secret)))
-    (erc-server-send (concat "JOIN " channel
-			     (if password
-				 (concat " " password)
-			       "")))))
-
 (defun erc-autojoin-add (proc parsed)
   "Add the channel being joined to `erc-autojoin-channels-alist'."
   (let* ((chnl (erc-response.contents parsed))
 	 (nick (car (erc-parse-user (erc-response.sender parsed))))
 	 (server (with-current-buffer (process-buffer proc)
-		   (or erc-server-announced-name erc-session-server))))
+		   (or erc-session-server erc-server-announced-name))))
     (when (erc-current-nick-p nick)
       (when (and erc-autojoin-domain-only
 		 (string-match "[^.\n]+\\.\\([^.\n]+\\.[^.\n]+\\)$" server))
@@ -209,7 +195,7 @@ erc-autojoin-remove
   (let* ((chnl (car (erc-response.command-args parsed)))
 	 (nick (car (erc-parse-user (erc-response.sender parsed))))
 	 (server (with-current-buffer (process-buffer proc)
-		   (or erc-server-announced-name erc-session-server))))
+		   (or erc-session-server erc-server-announced-name))))
     (when (erc-current-nick-p nick)
       (when (and erc-autojoin-domain-only
 		 (string-match "[^.\n]+\\.\\([^.\n]+\\.[^.\n]+\\)$" server))
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 3dcb7ef..3cc9f52 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -3022,6 +3022,23 @@ erc-cmd-HELP
 (defalias 'erc-cmd-H 'erc-cmd-HELP)
 (put 'erc-cmd-HELP 'process-not-needed t)
 
+(defun erc-server-join-channel (server channel &optional secret)
+  (let* ((secret (or secret
+		     (plist-get (nth 0 (auth-source-search
+					:max 1
+					:host server
+					:port "irc"
+					:user channel))
+				:secret)))
+	 (password (if (functionp secret)
+		       (funcall secret)
+		     secret)))
+    (erc-log (format "cmd: JOIN: %s" channel))
+    (erc-server-send (concat "JOIN " channel
+			     (if password
+				 (concat " " password)
+			       "")))))
+
 (defun erc-cmd-JOIN (channel &optional key)
   "Join the channel given in CHANNEL, optionally with KEY.
 If CHANNEL is specified as \"-invite\", join the channel to which you
@@ -3041,10 +3058,9 @@ erc-cmd-JOIN
         (if (erc-member-ignore-case chnl joined-channels)
             (switch-to-buffer (car (erc-member-ignore-case chnl
                                                            joined-channels)))
-          (erc-log (format "cmd: JOIN: %s" chnl))
-          (erc-server-send (if (and chnl key)
-                               (format "JOIN %s %s" chnl key)
-                             (format "JOIN %s" chnl)))))))
+	  (let ((server (with-current-buffer (process-buffer erc-server-process)
+			  (or erc-session-server erc-server-announced-name))))
+	    (erc-server-join-channel server chnl key))))))
   t)
 
 (defalias 'erc-cmd-CHANNEL 'erc-cmd-JOIN)





  reply	other threads:[~2017-01-06 15:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03 22:32 bug#25349: 25.1.90; erc join -vs- passwords Tom Tromey
2017-01-04  3:47 ` Nikolay Kudryavtsev
2017-01-04 11:07   ` Tom Tromey
2017-01-04 15:15     ` Tom Tromey
2017-01-05 22:36       ` Tom Tromey
2017-01-06 15:14         ` Tom Tromey [this message]
2017-01-10  3:35           ` Tom Tromey
2017-02-01  3:01             ` Tom Tromey
2017-01-05  2:20     ` Nikolay Kudryavtsev
2017-01-05  4:43       ` Tom Tromey
2017-01-04 15:13 ` Tom Tromey
2017-05-06  3:47 ` bug#25349: fix checked in Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878tqodxvk.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=25349@debbugs.gnu.org \
    --cc=nikolay.kudryavtsev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.