14
|
1 ;;; url-irc.el --- IRC URL interface
|
|
2 ;; Author: wmperry
|
16
|
3 ;; Created: 1997/01/10 00:13:05
|
|
4 ;; Version: 1.5
|
14
|
5 ;; Keywords: comm, data, processes
|
|
6
|
|
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
8 ;;; Copyright (c) 1996 by William M. Perry (wmperry@cs.indiana.edu)
|
16
|
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
|
14
|
10 ;;;
|
|
11 ;;; This file is not part of GNU Emacs, but the same permissions apply.
|
|
12 ;;;
|
|
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
14 ;;; it under the terms of the GNU General Public License as published by
|
|
15 ;;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;;; any later version.
|
|
17 ;;;
|
|
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
|
|
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 ;;; GNU General Public License for more details.
|
|
22 ;;;
|
|
23 ;;; You should have received a copy of the GNU General Public License
|
|
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
26 ;;; Boston, MA 02111-1307, USA.
|
|
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
28
|
|
29 (require 'url-vars)
|
|
30 (require 'url-parse)
|
|
31
|
|
32 (defvar url-irc-function 'url-irc-zenirc
|
|
33 "*Function to actually open an IRC connection.
|
|
34 Should be a function that takes several argument:
|
|
35 HOST - the hostname of the IRC server to contact
|
|
36 PORT - the port number of the IRC server to contact
|
|
37 CHANNEL - What channel on the server to visit right away (can be nil)
|
|
38 USER - What username to use
|
|
39 PASSWORD - What password to use")
|
|
40
|
|
41 (defun url-irc-zenirc (host port channel user password)
|
|
42 (let ((zenirc-buffer-name (if (and user host port)
|
|
43 (format "%s@%s:%d" user host port)
|
|
44 (format "%s:%d" host port)))
|
|
45 (zenirc-server-alist
|
|
46 (list
|
|
47 (list host port password nil user))))
|
|
48 (zenirc)
|
|
49 (goto-char (point-max))
|
|
50 (if (not channel)
|
|
51 nil
|
|
52 (insert "/join " channel)
|
|
53 (zenirc-send-line))))
|
|
54
|
|
55 (defun url-irc (url)
|
|
56 (let* ((urlobj (url-generic-parse-url url))
|
|
57 (host (url-host urlobj))
|
|
58 (port (string-to-int (url-port urlobj)))
|
|
59 (pass (url-password urlobj))
|
|
60 (user (url-user urlobj))
|
|
61 (chan (url-filename urlobj)))
|
|
62 (if (url-target urlobj)
|
|
63 (setq chan (concat chan "#" (url-target urlobj))))
|
|
64 (and (get-buffer url-working-buffer)
|
|
65 (kill-buffer url-working-buffer))
|
|
66 (if (string-match "^/" chan)
|
|
67 (setq chan (substring chan 1 nil)))
|
|
68 (if (= (length chan) 0)
|
|
69 (setq chan nil))
|
|
70 (funcall url-irc-function host port chan user pass)))
|
|
71
|