aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivek Dasmohapatra2010-08-14 18:58:10 -0400
committerChong Yidong2010-08-14 18:58:10 -0400
commit8a8d54cd2a7116c5aed4ecab7f5b14ae705ca740 (patch)
tree168f46d1eb3959da56e0164abdc00f98f0b09a62
parentab731e1cf3567059a906879c4e53306fa153c4c8 (diff)
downloademacs-8a8d54cd2a7116c5aed4ecab7f5b14ae705ca740.tar.gz
emacs-8a8d54cd2a7116c5aed4ecab7f5b14ae705ca740.zip
Allow delayed autojoin in ERC (Bug#5521).
* erc/erc-join.el (erc-autojoin-timing, erc-autojoin-delay): New vars. (erc-autojoin-channels-delayed, erc-autojoin-after-ident): New functions. (erc-autojoin-channels): Allow autojoining after ident (Bug#5521).
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/erc/ChangeLog7
-rw-r--r--lisp/erc/erc-join.el76
3 files changed, 87 insertions, 4 deletions
diff --git a/etc/NEWS b/etc/NEWS
index bef21ad3bdd..8e2594d8ace 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -213,6 +213,14 @@ automatically added to the primary window selection.
213 213
214** Archive Mode has basic support to browse 7z archives. 214** Archive Mode has basic support to browse 7z archives.
215 215
216** ERC changes
217
218*** New vars `erc-autojoin-timing' and `erc-autojoin-delay'.
219If the value of `erc-autojoin-timing' is 'ident, ERC autojoins after a
220successful NickServ identification, or after `erc-autojoin-delay'
221seconds. The default value, 'ident, means to autojoin immediately
222after connecting.
223
216** In ido-mode, C-v is no longer bound to ido-toggle-vc. 224** In ido-mode, C-v is no longer bound to ido-toggle-vc.
217The reason is that this interferes with cua-mode. 225The reason is that this interferes with cua-mode.
218 226
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog
index 6591db6cd94..90b3131ebd8 100644
--- a/lisp/erc/ChangeLog
+++ b/lisp/erc/ChangeLog
@@ -1,3 +1,10 @@
12010-08-14 Vivek Dasmohapatra <vivek@etla.org>
2
3 * erc-join.el (erc-autojoin-timing, erc-autojoin-delay): New vars.
4 (erc-autojoin-channels-delayed, erc-autojoin-after-ident): New
5 functions.
6 (erc-autojoin-channels): Allow autojoining after ident (Bug#5521).
7
12010-08-08 Fran Litterio <flitterio@gmail.com> 82010-08-08 Fran Litterio <flitterio@gmail.com>
2 9
3 * erc-backend.el (erc-server-filter-function): Call 10 * erc-backend.el (erc-server-filter-function): Call
diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el
index 7081d97fc4b..c54c2c534f3 100644
--- a/lisp/erc/erc-join.el
+++ b/lisp/erc/erc-join.el
@@ -42,9 +42,11 @@
42(define-erc-module autojoin nil 42(define-erc-module autojoin nil
43 "Makes ERC autojoin on connects and reconnects." 43 "Makes ERC autojoin on connects and reconnects."
44 ((add-hook 'erc-after-connect 'erc-autojoin-channels) 44 ((add-hook 'erc-after-connect 'erc-autojoin-channels)
45 (add-hook 'erc-nickserv-identified-hook 'erc-autojoin-after-ident)
45 (add-hook 'erc-server-JOIN-functions 'erc-autojoin-add) 46 (add-hook 'erc-server-JOIN-functions 'erc-autojoin-add)
46 (add-hook 'erc-server-PART-functions 'erc-autojoin-remove)) 47 (add-hook 'erc-server-PART-functions 'erc-autojoin-remove))
47 ((remove-hook 'erc-after-connect 'erc-autojoin-channels) 48 ((remove-hook 'erc-after-connect 'erc-autojoin-channels)
49 (remove-hook 'erc-nickserv-identified-hook 'erc-autojoin-after-ident)
48 (remove-hook 'erc-server-JOIN-functions 'erc-autojoin-add) 50 (remove-hook 'erc-server-JOIN-functions 'erc-autojoin-add)
49 (remove-hook 'erc-server-PART-functions 'erc-autojoin-remove))) 51 (remove-hook 'erc-server-PART-functions 'erc-autojoin-remove)))
50 52
@@ -66,6 +68,24 @@ time is used again."
66 (repeat :tag "Channels" 68 (repeat :tag "Channels"
67 (string :tag "Name"))))) 69 (string :tag "Name")))))
68 70
71(defcustom erc-autojoin-timing 'connect
72 "When ERC should attempt to autojoin a channel.
73If the value is `connect', autojoin immediately on connecting.
74If the value is `ident', autojoin after successful NickServ
75identification, or after `erc-autojoin-delay' seconds.
76Any other value means the same as `connect'."
77 :group 'erc-autojoin
78 :type '(choice (const :tag "On Connection" 'connect)
79 (const :tag "When Identified" 'ident)))
80
81(defcustom erc-autojoin-delay 30
82 "Number of seconds to wait before attempting to autojoin channels.
83This only takes effect if `erc-autojoin-timing' is `ident'.
84If NickServ identification occurs before this delay expires, ERC
85autojoins immediately at that time."
86 :group 'erc-autojoin
87 :type 'integer)
88
69(defcustom erc-autojoin-domain-only t 89(defcustom erc-autojoin-domain-only t
70 "Truncate host name to the domain name when joining a server. 90 "Truncate host name to the domain name when joining a server.
71If non-nil, and a channel on the server a.b.c is joined, then 91If non-nil, and a channel on the server a.b.c is joined, then
@@ -75,12 +95,60 @@ servers, presumably in the same domain."
75 :group 'erc-autojoin 95 :group 'erc-autojoin
76 :type 'boolean) 96 :type 'boolean)
77 97
98(defvar erc--autojoin-timer nil)
99(make-variable-buffer-local 'erc--autojoin-timer)
100
101(defun erc-autojoin-channels-delayed (server nick buffer)
102 "Attempt to autojoin channels.
103This is called from a timer set up by `erc-autojoin-channels'."
104 (if erc--autojoin-timer
105 (setq erc--autojoin-timer
106 (erc-cancel-timer erc--autojoin-timer)))
107 (with-current-buffer buffer
108 ;; Don't kick of another delayed autojoin or try to wait for
109 ;; another ident response:
110 (let ((erc-autojoin-delay -1)
111 (erc-autojoin-timing 'connect))
112 (erc-log "Delayed autojoin started (no ident success detected yet)")
113 (erc-autojoin-channels server nick))))
114
115(defun erc-autojoin-after-ident (network nick)
116 "Autojoin channels in `erc-autojoin-channels-alist'.
117This function is run from `erc-nickserv-identified-hook'."
118 (if erc--autojoin-timer
119 (setq erc--autojoin-timer
120 (erc-cancel-timer erc--autojoin-timer)))
121 (when (eq erc-autojoin-timing 'ident)
122 (let ((server (or erc-server-announced-name erc-session-server))
123 (joined (mapcar (lambda (buf)
124 (with-current-buffer buf (erc-default-target)))
125 (erc-channel-list erc-server-process))))
126 ;; We may already be in these channels, e.g. because the
127 ;; autojoin timer went off.
128 (dolist (l erc-autojoin-channels-alist)
129 (when (string-match (car l) server)
130 (dolist (chan (cdr l))
131 (unless (erc-member-ignore-case chan joined)
132 (erc-server-send (concat "join " chan))))))))
133 nil)
134
78(defun erc-autojoin-channels (server nick) 135(defun erc-autojoin-channels (server nick)
79 "Autojoin channels in `erc-autojoin-channels-alist'." 136 "Autojoin channels in `erc-autojoin-channels-alist'."
80 (dolist (l erc-autojoin-channels-alist) 137 (if (eq erc-autojoin-timing 'ident)
81 (when (string-match (car l) server) 138 ;; Prepare the delayed autojoin timer, in case ident doesn't
82 (dolist (chan (cdr l)) 139 ;; happen within the allotted time limit:
83 (erc-server-send (concat "join " chan)))))) 140 (when (> erc-autojoin-delay 0)
141 (setq erc--autojoin-timer
142 (run-with-timer erc-autojoin-delay nil
143 'erc-autojoin-channels-delayed
144 server nick (current-buffer))))
145 ;; `erc-autojoin-timing' is `connect':
146 (dolist (l erc-autojoin-channels-alist)
147 (when (string-match (car l) server)
148 (dolist (chan (cdr l))
149 (erc-server-send (concat "join " chan))))))
150 ;; Return nil to avoid stomping on any other hook funcs.
151 nil)
84 152
85(defun erc-autojoin-add (proc parsed) 153(defun erc-autojoin-add (proc parsed)
86 "Add the channel being joined to `erc-autojoin-channels-alist'." 154 "Add the channel being joined to `erc-autojoin-channels-alist'."