Mercurial > emacs
annotate lisp/url/url-irc.el @ 94934:669d4161a058
(image_ascent): Don't include "charset.h". Include
"character.h" and "font.h".
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 14 May 2008 01:39:03 +0000 |
parents | 8259d0d8e107 |
children | 7369ded3b436 |
rev | line source |
---|---|
54695 | 1 ;;; url-irc.el --- IRC URL interface |
57612 | 2 |
64748
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004, |
79720 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
57612 | 5 |
54695 | 6 ;; Keywords: comm, data, processes |
7 | |
57612 | 8 ;; This file is part of GNU Emacs. |
9 | |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
57612 | 11 ;; it under the terms of the GNU General Public License as published by |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
54695 | 14 |
57612 | 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. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
57612 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; IRC URLs are defined in http://www.w3.org/Addressing/draft-mirashi-url-irc-01.txt | |
26 | |
27 ;;; Code: | |
54695 | 28 |
29 (require 'url-vars) | |
30 (require 'url-parse) | |
31 | |
32 (defconst url-irc-default-port 6667 "Default port for IRC connections") | |
33 | |
69695
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
34 (defcustom url-irc-function 'url-irc-rcirc |
54695 | 35 "*Function to actually open an IRC connection. |
69695
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
36 Should be a function that takes several arguments: |
54695 | 37 HOST - the hostname of the IRC server to contact |
38 PORT - the port number of the IRC server to contact | |
39 CHANNEL - What channel on the server to visit right away (can be nil) | |
40 USER - What username to use | |
41 PASSWORD - What password to use" | |
69695
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
42 :type '(choice (const :tag "rcirc" :value url-irc-rcirc) |
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
43 (const :tag "ERC" :value url-irc-erc) |
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
44 (const :tag "ZEN IRC" :value url-irc-zenirc) |
54695 | 45 (function :tag "Other")) |
46 :group 'url) | |
47 | |
86822
997ca3d094a9
(zenirc, zenirc-send-line): Declare as functions.
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
48 ;; External. |
997ca3d094a9
(zenirc, zenirc-send-line): Declare as functions.
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
49 (declare-function zenirc "ext:zenirc" (&optional prefix)) |
997ca3d094a9
(zenirc, zenirc-send-line): Declare as functions.
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
50 (declare-function zenirc-send-line "ext:zenirc" ()) |
997ca3d094a9
(zenirc, zenirc-send-line): Declare as functions.
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
51 |
54695 | 52 (defun url-irc-zenirc (host port channel user password) |
53 (let ((zenirc-buffer-name (if (and user host port) | |
54 (format "%s@%s:%d" user host port) | |
55 (format "%s:%d" host port))) | |
56 (zenirc-server-alist | |
57 (list | |
58 (list host port password nil user)))) | |
59 (zenirc) | |
60 (goto-char (point-max)) | |
61 (if (not channel) | |
62 nil | |
63 (insert "/join " channel) | |
64 (zenirc-send-line)))) | |
65 | |
69695
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
66 (defun url-irc-rcirc (host port channel user password) |
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
67 (let ((chan (when channel (concat "#" channel)))) |
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
68 (rcirc-connect host port user nil nil (when chan (list chan))) |
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
69 (when chan |
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
70 (switch-to-buffer (concat chan "@" host))))) |
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
71 |
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
72 (defun url-irc-erc (host port channel user password) |
71883 | 73 (erc-handle-irc-url host port channel user password)) |
69695
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
74 |
54695 | 75 ;;;###autoload |
76 (defun url-irc (url) | |
77 (let* ((host (url-host url)) | |
57886
60d07d8a52e1
* url-imap.el (url-imap-open-host): Don't use
Masatake YAMATO <jet@gyve.org>
parents:
57612
diff
changeset
|
78 (port (url-port url)) |
54695 | 79 (pass (url-password url)) |
80 (user (url-user url)) | |
81 (chan (url-filename url))) | |
82 (if (url-target url) | |
83 (setq chan (concat chan "#" (url-target url)))) | |
84 (if (string-match "^/" chan) | |
85 (setq chan (substring chan 1 nil))) | |
86 (if (= (length chan) 0) | |
87 (setq chan nil)) | |
88 (funcall url-irc-function host port chan user pass) | |
89 nil)) | |
69695
20c95c0b0947
(url-irc-rcirc, url-irc-erc): New functions.
Romain Francoise <romain@orebokech.com>
parents:
68640
diff
changeset
|
90 |
54695 | 91 (provide 'url-irc) |
54699 | 92 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
93 ;; arch-tag: 2e5eecf8-9eb3-436b-9fbd-c26f2fb2bf3e |
57612 | 94 ;;; url-irc.el ends here |