Merged from mwolson@gnu.org--2006 (patch 24)
[planner-el.git] / planner-erc.el
blob4bc0cf219bcfb5e2655bf9d19a58b5651a306913
1 ;;; planner-erc.el --- ERC support for Planner, an organizer for Emacs
3 ;; Copyright (C) 2004 Free Software Foundation, Inc.
5 ;;; Commentary:
6 ;;
7 ;;;_* Commentary
9 ;;;_ + Package description
11 ;; Emacs Lisp Archive Entry
12 ;; Filename: planner-erc.el
13 ;; Keywords: hypermedia erc chat
14 ;; Author: Sacha Chua <sacha@free.net.ph>
15 ;; Description: Create tasks and notes based on IRC
16 ;; URL: http://www.plannerlove.com/
17 ;; Compatibility: Emacs20, Emacs21, XEmacs21
19 ;; This file is part of Planner. It is not part of GNU Emacs.
21 ;; Planner is free software; you can redistribute it and/or modify it
22 ;; under the terms of the GNU General Public License as published by
23 ;; the Free Software Foundation; either version 2, or (at your option)
24 ;; any later version.
26 ;; Planner is distributed in the hope that it will be useful, but
27 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 ;; General Public License for more details.
31 ;; You should have received a copy of the GNU General Public License
32 ;; along with Planner; see the file COPYING. If not, write to the
33 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
34 ;; Boston, MA 02110-1301, USA.
36 ;;;_ + Usage
38 ;; Place planner-erc.el in your load path and add this to your .emacs:
40 ;; (require 'planner-erc)
42 ;; ERC URLs are of the form
44 ;; erc://server/nick/channel or
45 ;; erc://server/nick or
46 ;; erc://server/nick
48 ;; Annotations will be of the form
49 ;; [[erc://server/nick/#channel][Chat with nick on server#channel]]
50 ;; [[erc://server/nick][Chat with nick on server]]
51 ;; [[erc://server][Chat on server]]
53 (require 'planner)
54 (require 'erc)
56 ;;; Code:
57 ;;;###autoload
58 (defun planner-erc-annotation-from-erc ()
59 "Return an annotation for the current line.
60 This function can be added to `planner-annotation-functions'."
61 (when (eq major-mode 'erc-mode)
62 (if (erc-default-target)
63 (if (erc-channel-p (erc-default-target))
64 (if (and (get-text-property (point) 'erc-parsed)
65 (elt (get-text-property (point) 'erc-parsed) 1))
66 (let ((nick
67 (car
68 (erc-parse-user
69 (elt (get-text-property (point) 'erc-parsed) 1)))))
70 (planner-make-link
71 (concat "irc://"
72 erc-announced-server-name "/"
73 (substring nick 1) ",isnick")
74 (concat "Chat with " nick " on "
75 erc-announced-server-name (erc-default-target))
76 t))
77 (planner-make-link
78 (concat "irc://"
79 erc-announced-server-name "/"
80 (erc-default-target))
81 (concat "Chat on " erc-announced-server-name
82 (erc-default-target))
83 t))
84 (planner-make-link
85 (concat "irc://" erc-announced-server-name "/"
86 (erc-default-target))
87 (concat "Chat with " (erc-default-target) " on "
88 erc-announced-server-name)
89 t))
90 (planner-make-link
91 (concat "irc://" erc-announced-server-name)
92 (concat "Chat on " erc-announced-server-name)
93 t))))
95 ;;;###autoload
96 (defun planner-erc-browse-url (url)
97 "If this is an ERC URL, jump to it.
98 This just connects to the server--you have to join the channel or privmsg
99 people yourself."
100 ;; If anyone can figure out how to get it to automatically open the
101 ;; channel window, that would be ultra cool.
102 ;; Also, we need a way to canonicalize going to a particular server.
103 ;; But this will do for now.
104 (when (string-match "\\`[ei]rc://\\([^/]+\\)" url)
105 (erc-select (match-string 1 url))
109 (planner-add-protocol "[ei]rc://" 'planner-erc-browse-url 'identity)
111 (add-hook 'planner-annotation-functions 'planner-erc-annotation-from-erc)
112 (custom-add-option 'planner-annotation-functions
113 'planner-erc-annotation-from-erc)
115 (planner-update-wiki-project)
116 (provide 'planner-erc)
118 ;;;_* Local emacs vars.
120 ;; Local variables:
121 ;; allout-layout: (* 0 : )
122 ;; End:
124 ;;; planner-erc.el ends here