planner-calendar: Make « and » work
[planner-el.git] / planner-wl.el
blobbe6c2b19e79f1330f4b9c9bc8bd49b072d150810
1 ;;; planner-wl.el --- Wanderlust integration for the Emacs Planner
3 ;; Copyright (C) 2004 Yvonne Thomson (yvonne AT netbrains DOT com DOT au)
4 ;; Parts copyright (C) 2004 Angus Lees (gus AT inodes DOT org)
6 ;; Author: Yvonne Thomson (yvonne AT thewatch DOT net)
7 ;; Keywords: planner, wanderlust, wl
8 ;; URL: http://www.wjsullivan.net/PlannerMode.html
10 ;; This file is part of Planner. It is not part of GNU Emacs.
12 ;; Planner is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
17 ;; Planner is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with Planner; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
27 ;;; Commentary:
29 ;; Add
31 ;; (require 'planner-wl)
33 ;; to your .emacs or .wl. You will then be able to call
34 ;; M-x planner-create-task-from-buffer from Wanderlust summary buffers
35 ;; with the correct annotation.
37 ;; To add keybindings to Wanderlust, call (from .emacs or .wl)
39 ;; (planner-wl-insinuate)
41 ;; This binds C-c C-t in summary buffers to `planner-create-task-from-buffer'
43 ;; Note:
44 ;; `planner-wl-annotation-from-wl' uses `wl-summary-from-function' (and
45 ;; related options) rather than `planner-ignored-from-addresses'
47 ;; URLs are of the form wl://foldername/msg-id
49 ;;;_ + Contributors
51 ;; Angus Lees (gus AT inodes DOT org) remade quite a bit of this file.
53 ;; Jeremy Cowgar (jeremy AT cowgar DOT com) updated this to work with
54 ;; Wanderlust 2.12.0.
56 ;;; Code:
58 (require 'planner)
59 (require 'wl)
60 (require 'wl-summary)
62 ;;;###autoload
63 (defun planner-wl-insinuate ()
64 "Hook Planner into Wanderlust.
65 Add special planner keybindings to`wl-summary-mode-map'.
66 From the Wanderlust Summary view, you can type C-c C-t to create a task."
67 (define-key wl-summary-mode-map (kbd "C-c C-t") 'planner-create-task-from-buffer))
69 ;;;###autoload
70 (defun planner-wl-annotation-from-wl ()
71 "If called from wl, return an annotation.
72 Suitable for use in `planner-annotation-functions'."
73 (when (equal major-mode 'wl-summary-mode)
74 (let* ((msgnum (wl-summary-message-number))
75 (msg-id (elmo-message-field wl-summary-buffer-elmo-folder
76 msgnum 'message-id))
77 (wl-message-entity
78 (if (fboundp 'elmo-message-entity)
79 (elmo-message-entity
80 wl-summary-buffer-elmo-folder msgnum)
81 (elmo-msgdb-overview-get-entity
82 msgnum (wl-summary-buffer-msgdb)))))
83 (planner-make-link
84 (concat "wl://" wl-summary-buffer-folder-name "/" msg-id)
85 (concat "E-Mail " (wl-summary-line-from))
86 t))))
88 ;;;###autoload
89 (defun planner-wl-browse-url (url)
90 "If this is a Wanderlust URL, jump to it."
91 (when (string-match "\\`wl:/*\\(.+\\)/\\(.+\\)" url)
92 (let ((group (match-string 1 url))
93 (article (match-string 2 url)))
94 (wl-summary-goto-folder-subr group 'no-sync t nil t)
95 (wl-summary-jump-to-msg-by-message-id article)
96 (wl-summary-redisplay)
97 ;; force a non-nil return value
98 t)))
100 (planner-add-protocol "wl:/*" 'planner-wl-browse-url nil)
101 (custom-add-option 'planner-annotation-functions
102 'planner-wl-annotation-from-wl)
103 (add-hook 'planner-annotation-functions 'planner-wl-annotation-from-wl)
105 (provide 'planner-wl)
107 ;;; planner-wl.el ends here