Mercurial > emacs
annotate lisp/erc/erc-join.el @ 110934:a36fccf2a365
lisp/net/telnet.el (telnet-mode-map): Fix previous change.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 12 Oct 2010 03:48:58 +0200 |
parents | 2abe46caa971 |
children | 417b1e4d63cd |
rev | line source |
---|---|
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
1 ;;; erc-join.el --- autojoin channels on connect and reconnects |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
2 |
106815 | 3 ;; Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
4 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
5 ;; Author: Alex Schroeder <alex@gnu.org> |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
6 ;; Keywords: irc |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
7 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcAutoJoin |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
8 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
10 |
94660
2a734255bcc7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79706
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
94660
2a734255bcc7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79706
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
2a734255bcc7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79706
diff
changeset
|
14 ;; (at your option) any later version. |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
15 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
20 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
94660
2a734255bcc7
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
79706
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
23 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
24 ;;; Commentary: |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
25 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
26 ;; This allows us to customize an `erc-autojoin-channels-alist'. As |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
27 ;; we /JOIN and /PART channels, this alist is updated to reflect our |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
28 ;; current setup, so that when we reconnect, we rejoin the same |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
29 ;; channels. The alist can be customized, so that the customized |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
30 ;; value will be used when we reconnect in our next Emacs session. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
31 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
32 ;;; Code: |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
33 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
34 (require 'erc) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
35 (eval-when-compile (require 'cl)) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
36 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
37 (defgroup erc-autojoin nil |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
38 "Enable autojoining." |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
39 :group 'erc) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
40 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
41 ;;;###autoload (autoload 'erc-autojoin-mode "erc-join" nil t) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
42 (define-erc-module autojoin nil |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
43 "Makes ERC autojoin on connects and reconnects." |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
44 ((add-hook 'erc-after-connect 'erc-autojoin-channels) |
109784
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
45 (add-hook 'erc-nickserv-identified-hook 'erc-autojoin-after-ident) |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
46 (add-hook 'erc-server-JOIN-functions 'erc-autojoin-add) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
47 (add-hook 'erc-server-PART-functions 'erc-autojoin-remove)) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
48 ((remove-hook 'erc-after-connect 'erc-autojoin-channels) |
109784
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
49 (remove-hook 'erc-nickserv-identified-hook 'erc-autojoin-after-ident) |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
50 (remove-hook 'erc-server-JOIN-functions 'erc-autojoin-add) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
51 (remove-hook 'erc-server-PART-functions 'erc-autojoin-remove))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
52 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
53 (defcustom erc-autojoin-channels-alist nil |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
54 "Alist of channels to autojoin on IRC networks. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
55 Every element in the alist has the form (SERVER . CHANNELS). |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
56 SERVER is a regexp matching the server, and channels is the |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
57 list of channels to join. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
58 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
59 Customize this variable to set the value for your first connect. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
60 Once you are connected and join and part channels, this alist |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
61 keeps track of what channels you are on, and will join them |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
62 again when you get disconnected. When you restart Emacs, however, |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
63 those changes are lost, and the customization you saved the last |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
64 time is used again." |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
65 :group 'erc-autojoin |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
66 :type '(repeat (cons :tag "Server" |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
67 (regexp :tag "Name") |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
68 (repeat :tag "Channels" |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
69 (string :tag "Name"))))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
70 |
109784
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
71 (defcustom erc-autojoin-timing 'connect |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
72 "When ERC should attempt to autojoin a channel. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
73 If the value is `connect', autojoin immediately on connecting. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
74 If the value is `ident', autojoin after successful NickServ |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
75 identification, or after `erc-autojoin-delay' seconds. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
76 Any other value means the same as `connect'." |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
77 :group 'erc-autojoin |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
78 :type '(choice (const :tag "On Connection" 'connect) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
79 (const :tag "When Identified" 'ident))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
80 |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
81 (defcustom erc-autojoin-delay 30 |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
82 "Number of seconds to wait before attempting to autojoin channels. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
83 This only takes effect if `erc-autojoin-timing' is `ident'. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
84 If NickServ identification occurs before this delay expires, ERC |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
85 autojoins immediately at that time." |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
86 :group 'erc-autojoin |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
87 :type 'integer) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
88 |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
89 (defcustom erc-autojoin-domain-only t |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
90 "Truncate host name to the domain name when joining a server. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
91 If non-nil, and a channel on the server a.b.c is joined, then |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
92 only b.c is used as the server for `erc-autojoin-channels-alist'. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
93 This is important for networks that redirect you to other |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
94 servers, presumably in the same domain." |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
95 :group 'erc-autojoin |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
96 :type 'boolean) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
97 |
109784
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
98 (defvar erc--autojoin-timer nil) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
99 (make-variable-buffer-local 'erc--autojoin-timer) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
100 |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
101 (defun erc-autojoin-channels-delayed (server nick buffer) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
102 "Attempt to autojoin channels. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
103 This is called from a timer set up by `erc-autojoin-channels'." |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
104 (if erc--autojoin-timer |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
105 (setq erc--autojoin-timer |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
106 (erc-cancel-timer erc--autojoin-timer))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
107 (with-current-buffer buffer |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
108 ;; Don't kick of another delayed autojoin or try to wait for |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
109 ;; another ident response: |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
110 (let ((erc-autojoin-delay -1) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
111 (erc-autojoin-timing 'connect)) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
112 (erc-log "Delayed autojoin started (no ident success detected yet)") |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
113 (erc-autojoin-channels server nick)))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
114 |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
115 (defun erc-autojoin-after-ident (network nick) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
116 "Autojoin channels in `erc-autojoin-channels-alist'. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
117 This function is run from `erc-nickserv-identified-hook'." |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
118 (if erc--autojoin-timer |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
119 (setq erc--autojoin-timer |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
120 (erc-cancel-timer erc--autojoin-timer))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
121 (when (eq erc-autojoin-timing 'ident) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
122 (let ((server (or erc-server-announced-name erc-session-server)) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
123 (joined (mapcar (lambda (buf) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
124 (with-current-buffer buf (erc-default-target))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
125 (erc-channel-list erc-server-process)))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
126 ;; We may already be in these channels, e.g. because the |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
127 ;; autojoin timer went off. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
128 (dolist (l erc-autojoin-channels-alist) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
129 (when (string-match (car l) server) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
130 (dolist (chan (cdr l)) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
131 (unless (erc-member-ignore-case chan joined) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
132 (erc-server-send (concat "join " chan)))))))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
133 nil) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
134 |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
135 (defun erc-autojoin-channels (server nick) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
136 "Autojoin channels in `erc-autojoin-channels-alist'." |
109784
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
137 (if (eq erc-autojoin-timing 'ident) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
138 ;; Prepare the delayed autojoin timer, in case ident doesn't |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
139 ;; happen within the allotted time limit: |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
140 (when (> erc-autojoin-delay 0) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
141 (setq erc--autojoin-timer |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
142 (run-with-timer erc-autojoin-delay nil |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
143 'erc-autojoin-channels-delayed |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
144 server nick (current-buffer)))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
145 ;; `erc-autojoin-timing' is `connect': |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
146 (dolist (l erc-autojoin-channels-alist) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
147 (when (string-match (car l) server) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
148 (dolist (chan (cdr l)) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
149 (erc-server-send (concat "join " chan)))))) |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
150 ;; Return nil to avoid stomping on any other hook funcs. |
2abe46caa971
Allow delayed autojoin in ERC (Bug#5521).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
151 nil) |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
152 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
153 (defun erc-autojoin-add (proc parsed) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
154 "Add the channel being joined to `erc-autojoin-channels-alist'." |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
155 (let* ((chnl (erc-response.contents parsed)) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
156 (nick (car (erc-parse-user (erc-response.sender parsed)))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
157 (server (with-current-buffer (process-buffer proc) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
158 (or erc-server-announced-name erc-session-server)))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
159 (when (erc-current-nick-p nick) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
160 (when (and erc-autojoin-domain-only |
69942
45937d0cd26d
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-208
Miles Bader <miles@gnu.org>
parents:
68822
diff
changeset
|
161 (string-match "[^.\n]+\\.\\([^.\n]+\\.[^.\n]+\\)$" server)) |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
162 (setq server (match-string 1 server))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
163 (let ((elem (assoc server erc-autojoin-channels-alist))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
164 (if elem |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
165 (unless (member chnl (cdr elem)) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
166 (setcdr elem (cons chnl (cdr elem)))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
167 (setq erc-autojoin-channels-alist |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
168 (cons (list server chnl) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
169 erc-autojoin-channels-alist)))))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
170 ;; We must return nil to tell ERC to continue running the other |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
171 ;; functions. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
172 nil) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
173 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
174 ;; (erc-parse-user "kensanata!~user@dclient217-162-233-228.hispeed.ch") |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
175 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
176 (defun erc-autojoin-remove (proc parsed) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
177 "Remove the channel being left from `erc-autojoin-channels-alist'." |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
178 (let* ((chnl (car (erc-response.command-args parsed))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
179 (nick (car (erc-parse-user (erc-response.sender parsed)))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
180 (server (with-current-buffer (process-buffer proc) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
181 (or erc-server-announced-name erc-session-server)))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
182 (when (erc-current-nick-p nick) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
183 (when (and erc-autojoin-domain-only |
69942
45937d0cd26d
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-208
Miles Bader <miles@gnu.org>
parents:
68822
diff
changeset
|
184 (string-match "[^.\n]+\\.\\([^.\n]+\\.[^.\n]+\\)$" server)) |
68719
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
185 (setq server (match-string 1 server))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
186 (let ((elem (assoc server erc-autojoin-channels-alist))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
187 (when elem |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
188 (setcdr elem (delete chnl (cdr elem))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
189 (unless (cdr elem) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
190 (setq erc-autojoin-channels-alist |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
191 (delete elem erc-autojoin-channels-alist))))))) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
192 ;; We must return nil to tell ERC to continue running the other |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
193 ;; functions. |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
194 nil) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
195 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
196 (provide 'erc-join) |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
197 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
198 ;;; erc-join.el ends here |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
199 ;; |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
200 ;; Local Variables: |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
201 ;; indent-tabs-mode: t |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
202 ;; tab-width: 8 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
203 ;; End: |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
204 |
2de3fcf69715
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-55
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
205 ;; arch-tag: d62d8b15-8e31-49d6-8a73-12f11e717414 |