From: Tom Tromey Date: Thu, 5 Jan 2017 14:11:06 +0000 (-0700) Subject: Fix erc-join with channel password X-Git-Tag: emacs-26.0.90~521^2~460 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=927dcbd2e6e0e53fcfb09296716e11c002ab1518;p=emacs.git Fix erc-join with channel password Bug#25349 * lisp/erc/erc-join.el (erc-autojoin-after-ident): Switch order of server names. (erc-autojoin-channels, erc-autojoin-add, erc-autojoin-remove): Likewise. (erc-server-join-channel): Move to erc.el. * lisp/erc/erc.el (erc-server-join-channel): Move from erc-join.el. (erc-cmd-JOIN): Use erc-server-join-channel. --- diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el index 151ea15f077..aa83ffe92ac 100644 --- a/lisp/erc/erc-join.el +++ b/lisp/erc/erc-join.el @@ -129,7 +129,7 @@ This function is run from `erc-nickserv-identified-hook'." (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 @@ This function is run from `erc-nickserv-identified-hook'." ;; `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 @@ This function is run from `erc-nickserv-identified-hook'." (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 8c65016ed22..8547821f080 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -3030,6 +3030,23 @@ For a list of user commands (/join /part, ...): (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 @@ -3049,10 +3066,9 @@ were most recently invited. See also `invitation'." (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)