annotate lisp/url/url-irc.el @ 61539:6f238601cd3f

*** empty log message ***
author Luc Teirlinck <teirllm@auburn.edu>
date Wed, 13 Apr 2005 22:13:32 +0000
parents 60d07d8a52e1
children a8fa7c632ee4 7a0245dd1848
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
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
3 ;; Copyright (c) 1996 - 1999 Free Software Foundation, Inc.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
4
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; Keywords: comm, data, processes
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
7 ;; This file is part of GNU Emacs.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
8
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
12 ;; any later version.
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
14 ;; 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
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
17 ;; GNU General Public License for more details.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
18
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
19 ;; You should have received a copy of the GNU General Public License
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
22 ;; Boston, MA 02111-1307, USA.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
23
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
24 ;;; Commentary:
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
25
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
26 ;; IRC URLs are defined in http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt
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
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 (defconst url-irc-default-port 6667 "Default port for IRC connections")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 (defcustom url-irc-function 'url-irc-zenirc
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 "*Function to actually open an IRC connection.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 Should be a function that takes several argument:
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"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 :type '(choice (const :tag "ZEN IRC" :value 'url-irc-zenirc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 (function :tag "Other"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 :group 'url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 (defun url-irc-zenirc (host port channel user password)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 (let ((zenirc-buffer-name (if (and user host port)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 (format "%s@%s:%d" user host port)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (format "%s:%d" host port)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 (zenirc-server-alist
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 (list
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 (list host port password nil user))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 (zenirc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 (goto-char (point-max))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 (if (not channel)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 (insert "/join " channel)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 (zenirc-send-line))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 (defun url-irc (url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 (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
64 (port (url-port url))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (pass (url-password url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 (user (url-user url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 (chan (url-filename url)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 (if (url-target url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 (setq chan (concat chan "#" (url-target url))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 (if (string-match "^/" chan)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 (setq chan (substring chan 1 nil)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 (if (= (length chan) 0)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 (setq chan nil))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 (funcall url-irc-function host port chan user pass)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 nil))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 (provide 'url-irc)
54699
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
78
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
79 ;;; arch-tag: 2e5eecf8-9eb3-436b-9fbd-c26f2fb2bf3e
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57427
diff changeset
80 ;;; url-irc.el ends here