Commit | Line | Data |
---|---|---|
8c8b8430 | 1 | ;;; url-irc.el --- IRC URL interface |
00eef4de LH |
2 | |
3 | ;; Copyright (c) 1996 - 1999 Free Software Foundation, Inc. | |
4 | ||
8c8b8430 SM |
5 | ;; Keywords: comm, data, processes |
6 | ||
00eef4de LH |
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. | |
13 | ||
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 | |
4fc5845f LK |
21 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 | ;; Boston, MA 02110-1301, USA. | |
00eef4de LH |
23 | |
24 | ;;; Commentary: | |
25 | ||
26 | ;; IRC URLs are defined in http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt | |
8c8b8430 | 27 | |
00eef4de | 28 | ;;; Code: |
8c8b8430 SM |
29 | |
30 | (require 'url-vars) | |
31 | (require 'url-parse) | |
32 | ||
33 | (defconst url-irc-default-port 6667 "Default port for IRC connections") | |
34 | ||
35 | (defcustom url-irc-function 'url-irc-zenirc | |
36 | "*Function to actually open an IRC connection. | |
37 | Should be a function that takes several argument: | |
38 | HOST - the hostname of the IRC server to contact | |
39 | PORT - the port number of the IRC server to contact | |
40 | CHANNEL - What channel on the server to visit right away (can be nil) | |
41 | USER - What username to use | |
42 | PASSWORD - What password to use" | |
43 | :type '(choice (const :tag "ZEN IRC" :value 'url-irc-zenirc) | |
44 | (function :tag "Other")) | |
45 | :group 'url) | |
46 | ||
47 | (defun url-irc-zenirc (host port channel user password) | |
48 | (let ((zenirc-buffer-name (if (and user host port) | |
49 | (format "%s@%s:%d" user host port) | |
50 | (format "%s:%d" host port))) | |
51 | (zenirc-server-alist | |
52 | (list | |
53 | (list host port password nil user)))) | |
54 | (zenirc) | |
55 | (goto-char (point-max)) | |
56 | (if (not channel) | |
57 | nil | |
58 | (insert "/join " channel) | |
59 | (zenirc-send-line)))) | |
60 | ||
61 | ;;;###autoload | |
62 | (defun url-irc (url) | |
63 | (let* ((host (url-host url)) | |
60b5eb78 | 64 | (port (url-port url)) |
8c8b8430 SM |
65 | (pass (url-password url)) |
66 | (user (url-user url)) | |
67 | (chan (url-filename url))) | |
68 | (if (url-target url) | |
69 | (setq chan (concat chan "#" (url-target url)))) | |
70 | (if (string-match "^/" chan) | |
71 | (setq chan (substring chan 1 nil))) | |
72 | (if (= (length chan) 0) | |
73 | (setq chan nil)) | |
74 | (funcall url-irc-function host port chan user pass) | |
75 | nil)) | |
76 | ||
77 | (provide 'url-irc) | |
e5566bd5 MB |
78 | |
79 | ;;; arch-tag: 2e5eecf8-9eb3-436b-9fbd-c26f2fb2bf3e | |
00eef4de | 80 | ;;; url-irc.el ends here |