Whitespace change.
[emacs.git] / lisp / url / url-irc.el
blob6b62761d97ae8f79b429b35c98d358e7597e6b14
1 ;;; url-irc.el --- IRC URL interface
2 ;; Keywords: comm, data, processes
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5 ;;; Copyright (c) 1996 by William M. Perry <wmperry@cs.indiana.edu>
6 ;;; Copyright (c) 1996 - 1999 Free Software Foundation, Inc.
7 ;;;
8 ;;; This file is part of GNU Emacs.
9 ;;;
10 ;;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 2, or (at your option)
13 ;;; any later version.
14 ;;;
15 ;;; GNU Emacs is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;;; Boston, MA 02111-1307, USA.
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;;; IRC URLs are defined in http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt
28 (require 'url-vars)
29 (require 'url-parse)
31 (defconst url-irc-default-port 6667 "Default port for IRC connections")
33 (defcustom url-irc-function 'url-irc-zenirc
34 "*Function to actually open an IRC connection.
35 Should be a function that takes several argument:
36 HOST - the hostname of the IRC server to contact
37 PORT - the port number of the IRC server to contact
38 CHANNEL - What channel on the server to visit right away (can be nil)
39 USER - What username to use
40 PASSWORD - What password to use"
41 :type '(choice (const :tag "ZEN IRC" :value 'url-irc-zenirc)
42 (function :tag "Other"))
43 :group 'url)
45 (defun url-irc-zenirc (host port channel user password)
46 (let ((zenirc-buffer-name (if (and user host port)
47 (format "%s@%s:%d" user host port)
48 (format "%s:%d" host port)))
49 (zenirc-server-alist
50 (list
51 (list host port password nil user))))
52 (zenirc)
53 (goto-char (point-max))
54 (if (not channel)
55 nil
56 (insert "/join " channel)
57 (zenirc-send-line))))
59 ;;;###autoload
60 (defun url-irc (url)
61 (let* ((host (url-host url))
62 (port (string-to-int (url-port url)))
63 (pass (url-password url))
64 (user (url-user url))
65 (chan (url-filename url)))
66 (if (url-target url)
67 (setq chan (concat chan "#" (url-target url))))
68 (if (string-match "^/" chan)
69 (setq chan (substring chan 1 nil)))
70 (if (= (length chan) 0)
71 (setq chan nil))
72 (funcall url-irc-function host port chan user pass)
73 nil))
75 (provide 'url-irc)
77 ;;; arch-tag: 2e5eecf8-9eb3-436b-9fbd-c26f2fb2bf3e