annotate lisp/url/url-irc.el @ 74:54cc21c15cbb r20-0b32

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