1 ;;; url-irc.el --- IRC URL interface
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Keywords: comm, data, processes
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
27 ;; IRC URLs are defined in http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt
34 (defconst url-irc-default-port
6667 "Default port for IRC connections")
36 (defcustom url-irc-function
'url-irc-rcirc
37 "*Function to actually open an IRC connection.
38 Should be a function that takes several arguments:
39 HOST - the hostname of the IRC server to contact
40 PORT - the port number of the IRC server to contact
41 CHANNEL - What channel on the server to visit right away (can be nil)
42 USER - What username to use
43 PASSWORD - What password to use"
44 :type
'(choice (const :tag
"rcirc" :value url-irc-rcirc
)
45 (const :tag
"ERC" :value url-irc-erc
)
46 (const :tag
"ZEN IRC" :value url-irc-zenirc
)
47 (function :tag
"Other"))
50 (defun url-irc-zenirc (host port channel user password
)
51 (let ((zenirc-buffer-name (if (and user host port
)
52 (format "%s@%s:%d" user host port
)
53 (format "%s:%d" host port
)))
56 (list host port password nil user
))))
58 (goto-char (point-max))
61 (insert "/join " channel
)
64 (defun url-irc-rcirc (host port channel user password
)
65 (let ((chan (when channel
(concat "#" channel
))))
66 (rcirc-connect host port user nil nil
(when chan
(list chan
)))
68 (switch-to-buffer (concat chan
"@" host
)))))
70 (defun url-irc-erc (host port channel user password
)
71 (erc-handle-irc-url host port channel user password
))
75 (let* ((host (url-host url
))
77 (pass (url-password url
))
79 (chan (url-filename url
)))
81 (setq chan
(concat chan
"#" (url-target url
))))
82 (if (string-match "^/" chan
)
83 (setq chan
(substring chan
1 nil
)))
84 (if (= (length chan
) 0)
86 (funcall url-irc-function host port chan user pass
)
91 ;;; arch-tag: 2e5eecf8-9eb3-436b-9fbd-c26f2fb2bf3e
92 ;;; url-irc.el ends here