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