annotate lisp/url/url-irc.el @ 110453:cb1da66792a4

Check in missing ChangeLog entry.
author Dan Nicolaescu <dann@ics.uci.edu>
date Tue, 21 Sep 2010 09:36:01 +0300
parents 5495085c9b6c
children 417b1e4d63cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; url-irc.el --- IRC URL interface
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
2
110307
5495085c9b6c lisp/url tiny fixes.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004, 2005, 2006, 2007, 2008,
5495085c9b6c lisp/url tiny fixes.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
4 ;; 2009, 2010 Free Software Foundation, Inc.
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
5
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Keywords: comm, data, processes
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
8 ;; This file is part of GNU Emacs.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
9
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; (at your option) any later version.
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
18 ;; GNU General Public License for more details.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
19
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
22
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
23 ;;; Commentary:
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
24
110307
5495085c9b6c lisp/url tiny fixes.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
25 ;; IRC URLs are defined in
5495085c9b6c lisp/url tiny fixes.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
26 ;; http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
27
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
28 ;;; Code:
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 (require 'url-vars)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 (require 'url-parse)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32
96486
7369ded3b436 Typo and docstring fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94668
diff changeset
33 (defconst url-irc-default-port 6667 "Default port for IRC connections.")
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34
69695
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
35 (defcustom url-irc-function 'url-irc-rcirc
110307
5495085c9b6c lisp/url tiny fixes.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
36 "Function to actually open an IRC connection.
96486
7369ded3b436 Typo and docstring fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 94668
diff changeset
37 The function should take the following arguments:
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 HOST - the hostname of the IRC server to contact
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 PORT - the port number of the IRC server to contact
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 CHANNEL - What channel on the server to visit right away (can be nil)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 USER - What username to use
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 PASSWORD - What password to use"
69695
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
43 :type '(choice (const :tag "rcirc" :value url-irc-rcirc)
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
44 (const :tag "ERC" :value url-irc-erc)
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
45 (const :tag "ZEN IRC" :value url-irc-zenirc)
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 (function :tag "Other"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 :group 'url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48
86822
997ca3d094a9 (zenirc, zenirc-send-line): Declare as functions.
Glenn Morris <rgm@gnu.org>
parents: 78222
diff changeset
49 ;; External.
997ca3d094a9 (zenirc, zenirc-send-line): Declare as functions.
Glenn Morris <rgm@gnu.org>
parents: 78222
diff changeset
50 (declare-function zenirc "ext:zenirc" (&optional prefix))
997ca3d094a9 (zenirc, zenirc-send-line): Declare as functions.
Glenn Morris <rgm@gnu.org>
parents: 78222
diff changeset
51 (declare-function zenirc-send-line "ext:zenirc" ())
997ca3d094a9 (zenirc, zenirc-send-line): Declare as functions.
Glenn Morris <rgm@gnu.org>
parents: 78222
diff changeset
52
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 (defun url-irc-zenirc (host port channel user password)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 (let ((zenirc-buffer-name (if (and user host port)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 (format "%s@%s:%d" user host port)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 (format "%s:%d" host port)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 (zenirc-server-alist
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 (list
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 (list host port password nil user))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 (zenirc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 (goto-char (point-max))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 (if (not channel)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 (insert "/join " channel)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (zenirc-send-line))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66
69695
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
67 (defun url-irc-rcirc (host port channel user password)
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
68 (let ((chan (when channel (concat "#" channel))))
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
69 (rcirc-connect host port user nil nil (when chan (list chan)))
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
70 (when chan
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
71 (switch-to-buffer (concat chan "@" host)))))
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
72
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
73 (defun url-irc-erc (host port channel user password)
71883
3d0d6e217db9 Update for ERC 5.1.3.
Miles Bader <miles@gnu.org>
parents: 69698
diff changeset
74 (erc-handle-irc-url host port channel user password))
69695
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
75
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 (defun url-irc (url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 (let* ((host (url-host url))
57886
60d07d8a52e1 * url-imap.el (url-imap-open-host): Don't use
Masatake YAMATO <jet@gyve.org>
parents: 57612
diff changeset
79 (port (url-port url))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 (pass (url-password url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 (user (url-user url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 (chan (url-filename url)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 (if (url-target url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 (setq chan (concat chan "#" (url-target url))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 (if (string-match "^/" chan)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 (setq chan (substring chan 1 nil)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 (if (= (length chan) 0)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 (setq chan nil))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 (funcall url-irc-function host port chan user pass)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 nil))
69695
20c95c0b0947 (url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents: 68640
diff changeset
91
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 (provide 'url-irc)
54699
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
93
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
94 ;; arch-tag: 2e5eecf8-9eb3-436b-9fbd-c26f2fb2bf3e
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
95 ;;; url-irc.el ends here