From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Olson Newsgroups: gmane.emacs.bugs Subject: bug#5521: 23.1; erc - allow autojoin to be delayed till after services ident Date: Sat, 17 Jul 2010 21:21:29 -0700 Message-ID: References: <871vb1he8j.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1279427441 26300 80.91.229.12 (18 Jul 2010 04:30:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 18 Jul 2010 04:30:41 +0000 (UTC) Cc: 5521@debbugs.gnu.org, Vivek Dasmohapatra To: Chong Yidong , Giorgos Keramidas , ERC Discussion Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 18 06:30:39 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OaLWQ-0005gL-2o for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Jul 2010 06:30:38 +0200 Original-Received: from localhost ([127.0.0.1]:47323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OaLWP-0000Zt-6w for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Jul 2010 00:30:37 -0400 Original-Received: from [140.186.70.92] (port=37071 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OaLWJ-0000Zl-H4 for bug-gnu-emacs@gnu.org; Sun, 18 Jul 2010 00:30:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OaLWI-00013N-Dt for bug-gnu-emacs@gnu.org; Sun, 18 Jul 2010 00:30:31 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52008) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OaLWI-00013I-8o for bug-gnu-emacs@gnu.org; Sun, 18 Jul 2010 00:30:30 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OaLO6-0001tw-Ff; Sun, 18 Jul 2010 00:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Olson Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Jul 2010 04:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5521 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 5521-submit@debbugs.gnu.org id=B5521.12794268957300 (code B ref 5521); Sun, 18 Jul 2010 04:22:02 +0000 Original-Received: (at 5521) by debbugs.gnu.org; 18 Jul 2010 04:21:35 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OaLNe-0001th-Nv for submit@debbugs.gnu.org; Sun, 18 Jul 2010 00:21:35 -0400 Original-Received: from mail-vw0-f44.google.com ([209.85.212.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OaLNc-0001tb-S2 for 5521@debbugs.gnu.org; Sun, 18 Jul 2010 00:21:33 -0400 Original-Received: by vws18 with SMTP id 18so28632vws.3 for <5521@debbugs.gnu.org>; Sat, 17 Jul 2010 21:21:50 -0700 (PDT) Original-Received: by 10.220.168.213 with SMTP id v21mr1853738vcy.274.1279426909493; Sat, 17 Jul 2010 21:21:49 -0700 (PDT) Original-Received: by 10.220.72.69 with HTTP; Sat, 17 Jul 2010 21:21:29 -0700 (PDT) X-Originating-IP: [99.66.24.246] In-Reply-To: <871vb1he8j.fsf@stupidchicken.com> X-Google-Sender-Auth: Zyo9rJW2zO0qiVWhjGDrv9_Xxro X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 18 Jul 2010 00:22:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:38650 Archived-At: Looks generally OK to me, though I've stepped down as the maintainer of ERC. Forwarding on to the ERC discussion list and the new maintainer Giorgos. One change I would recommend is to change :connect and :ident to be in normal symbol form ('connect and 'ident) for consistency with the rest of ERC's code. On Sat, Jul 17, 2010 at 4:37 PM, Chong Yidong wrote= : >> Some irc channels can only be joined by identified users, but since >> identification may not happen until some time after a server >> connection is established, autojoin currently happens too early for >> these channels. > >> This patch allows the autojoin timing to be selected: > >> =C2=A0- on connect (as currently) >> =C2=A0- after successful ident > >> If after-ident is chosen, there is also a customiseable timeout which >> kicks in and starts autojoin anyway if an ident isn't received in the >> alloted time. > > Hi Michael, > > Any objection to checking in this patch? =C2=A0(I did some cleanup of wha= t > Vivek originally sent). > > > > *** lisp/erc/erc-join.el =C2=A0 =C2=A0 =C2=A0 =C2=A02010-01-13 08:35:10 += 0000 > --- lisp/erc/erc-join.el =C2=A0 =C2=A0 =C2=A0 =C2=A02010-07-17 23:34:40 += 0000 > *************** > *** 42,50 **** > --- 42,52 ---- > =C2=A0(define-erc-module autojoin nil > =C2=A0 =C2=A0"Makes ERC autojoin on connects and reconnects." > =C2=A0 =C2=A0((add-hook 'erc-after-connect 'erc-autojoin-channels) > + =C2=A0 =C2=A0(add-hook 'erc-nickserv-identified-hook 'erc-autojoin-afte= r-ident) > =C2=A0 =C2=A0 (add-hook 'erc-server-JOIN-functions 'erc-autojoin-add) > =C2=A0 =C2=A0 (add-hook 'erc-server-PART-functions 'erc-autojoin-remove)) > =C2=A0 =C2=A0((remove-hook 'erc-after-connect 'erc-autojoin-channels) > + =C2=A0 =C2=A0(remove-hook 'erc-nickserv-identified-hook 'erc-autojoin-a= fter-ident) > =C2=A0 =C2=A0 (remove-hook 'erc-server-JOIN-functions 'erc-autojoin-add) > =C2=A0 =C2=A0 (remove-hook 'erc-server-PART-functions 'erc-autojoin-remov= e))) > > *************** > *** 66,71 **** > --- 68,91 ---- > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (repeat :tag "Channels" > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (string :tag "Name"))))) > > + (defcustom erc-autojoin-timing :connect > + =C2=A0 "When ERC should attempt to autojoin a channel. > + If the value is `:connect', autojoin immediately on connecting. > + If the value is `:ident', autojoin after successful NickServ > + identification, or after `erc-autojoin-delay' seconds. > + Any other value means the same as `:connect'." > + =C2=A0 :group 'erc-autojoin > + =C2=A0 :type =C2=A0'(choice (const :tag "On Connection" :connect) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (const :tag "Wh= en Identified" :ident))) > + > + (defcustom erc-autojoin-delay 30 > + =C2=A0 "Number of seconds to wait before attempting to autojoin channel= s. > + This only takes effect if `erc-autojoin-timing' is `:ident'. > + If NickServ identification occurs before this delay expires, ERC > + autojoins immediately at that time." > + =C2=A0 :group 'erc-autojoin > + =C2=A0 :type =C2=A0'integer) > + > =C2=A0(defcustom erc-autojoin-domain-only t > =C2=A0 =C2=A0"Truncate host name to the domain name when joining a server= . > =C2=A0If non-nil, and a channel on the server a.b.c is joined, then > *************** > *** 75,86 **** > =C2=A0 =C2=A0:group 'erc-autojoin > =C2=A0 =C2=A0:type 'boolean) > > =C2=A0(defun erc-autojoin-channels (server nick) > =C2=A0 =C2=A0"Autojoin channels in `erc-autojoin-channels-alist'." > ! =C2=A0 (dolist (l erc-autojoin-channels-alist) > ! =C2=A0 =C2=A0 (when (string-match (car l) server) > ! =C2=A0 =C2=A0 =C2=A0 (dolist (chan (cdr l)) > ! =C2=A0 =C2=A0 =C2=A0 (erc-server-send (concat "join " chan)))))) > > =C2=A0(defun erc-autojoin-add (proc parsed) > =C2=A0 =C2=A0"Add the channel being joined to `erc-autojoin-channels-alis= t'." > --- 95,154 ---- > =C2=A0 =C2=A0:group 'erc-autojoin > =C2=A0 =C2=A0:type 'boolean) > > + (defvar erc-autojoin-timer nil) > + (make-variable-buffer-local 'erc-autojoin-timer) > + > + (defun erc-autojoin-channels-delayed (server nick buffer) > + =C2=A0 "Attempt to autojoin channels. > + This is called from a timer set up by `erc-autojoin-channels'." > + =C2=A0 (if erc-autojoin-timer > + =C2=A0 =C2=A0 =C2=A0 (setq erc-autojoin-timer > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (erc-cancel-timer erc-autojoin-timer= ))) > + =C2=A0 (with-current-buffer buffer > + =C2=A0 =C2=A0 ;; Don't kick of another delayed autojoin or try to wait = for > + =C2=A0 =C2=A0 ;; another ident response: > + =C2=A0 =C2=A0 (let ((erc-autojoin-delay -1) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 (erc-autojoin-timing :connect)) > + =C2=A0 =C2=A0 =C2=A0 (erc-log "Delayed autojoin started (no ident succe= ss detected yet)") > + =C2=A0 =C2=A0 =C2=A0 (erc-autojoin-channels server nick)))) > + > + (defun erc-autojoin-after-ident (network nick) > + =C2=A0 "Autojoin channels in `erc-autojoin-channels-alist'. > + This function is run from `erc-nickserv-identified-hook'." > + =C2=A0 (if erc-autojoin-timer > + =C2=A0 =C2=A0 =C2=A0 (setq erc-autojoin-timer > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (erc-cancel-timer erc-autojoin-timer= ))) > + =C2=A0 (when (eq erc-autojoin-timing :ident) > + =C2=A0 =C2=A0 (let ((server (or erc-server-announced-name erc-session-s= erver)) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 (joined (mapcar (lambda (buf) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 (with-current-buffer buf (erc-default-target))) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (erc-channel-list erc-server-process)))) > + =C2=A0 =C2=A0 =C2=A0 ;; We may already be in these channels, e.g. becau= se the > + =C2=A0 =C2=A0 =C2=A0 ;; autojoin timer went off. > + =C2=A0 =C2=A0 =C2=A0 (dolist (l erc-autojoin-channels-alist) > + =C2=A0 =C2=A0 =C2=A0 (when (string-match (car l) server) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 (dolist (chan (cdr l)) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless (erc-member-ignore-case chan= joined) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (erc-server-send (concat "joi= n " chan)))))))) > + =C2=A0 nil) > + > =C2=A0(defun erc-autojoin-channels (server nick) > =C2=A0 =C2=A0"Autojoin channels in `erc-autojoin-channels-alist'." > ! =C2=A0 (if (eq erc-autojoin-timing :ident) > ! =C2=A0 =C2=A0 =C2=A0 ;; Prepare the delayed autojoin timer, in case ide= nt doesn't > ! =C2=A0 =C2=A0 =C2=A0 ;; happen within the allotted time limit: > ! =C2=A0 =C2=A0 =C2=A0 (when (> erc-autojoin-delay 0) > ! =C2=A0 =C2=A0 =C2=A0 (setq erc-autojoin-timer > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (run-with-timer erc-autojoin-= delay nil > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 'erc-autojoin-channels-delayed > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 server nick (current-buffer)))) > ! =C2=A0 =C2=A0 ;; `erc-autojoin-timing' is `:connect': > ! =C2=A0 =C2=A0 (dolist (l erc-autojoin-channels-alist) > ! =C2=A0 =C2=A0 =C2=A0 (when (string-match (car l) server) > ! =C2=A0 =C2=A0 =C2=A0 (dolist (chan (cdr l)) > ! =C2=A0 =C2=A0 =C2=A0 =C2=A0 (erc-server-send (concat "join " chan)))))) > ! =C2=A0 ;; Return nil to avoid stomping on any other hook funcs. > ! =C2=A0 nil) > > =C2=A0(defun erc-autojoin-add (proc parsed) > =C2=A0 =C2=A0"Add the channel being joined to `erc-autojoin-channels-alis= t'." > --=20 Michael Olson | http://mwolson.org/