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