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