~ubuntu-branches/ubuntu/quantal/maildir-utils/quantal

« back to all changes in this revision

Viewing changes to emacs/org-mu4e.el

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2012-03-15 08:45:56 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20120315084556-vqdvw8sgodo24aji
Tags: 0.9.8.2-1
* several new upstream versions
* b-d on libgmime-2.6-dev (Closes: #664001, #664006)
* bump standards version to 3.9.3, no changes necessary
* switch to source format 3.0 (quilt): debian/control, debian/rules
* maildir-utils depends on dpkg/install-info (lintian warning)
* fix man page lintian warnings

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;;; org-mu4e -- Support for links to mu4e messages/queries from within org-mode
 
2
;;
 
3
;; Copyright (C) 2012 Dirk-Jan C. Binnema
 
4
 
 
5
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
 
6
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
 
7
;; Keywords: outlines, hypermedia, calendar, mail
 
8
;; Version: 0.0
 
9
 
 
10
;; This file is not part of GNU Emacs.
 
11
;;
 
12
;; GNU Emacs is free software: you can redistribute it and/or modify
 
13
;; it under the terms of the GNU General Public License as published by
 
14
;; the Free Software Foundation, either version 3 of the License, or
 
15
;; (at your option) any later version.
 
16
 
 
17
;; GNU Emacs is distributed in the hope that it will be useful,
 
18
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
;; GNU General Public License for more details.
 
21
 
 
22
;; You should have received a copy of the GNU General Public License
 
23
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
24
 
 
25
;;; Commentary:
 
26
 
 
27
;;; Code:
 
28
 
 
29
(require 'org)
 
30
(eval-when-compile (require 'cl))
 
31
(eval-when-compile (require 'mu4e))
 
32
 
 
33
(defun org-mu4e-store-link ()
 
34
  "Store a link to a mu4e query or message."
 
35
  (cond
 
36
    ;; storing links to queries
 
37
    ((eq major-mode 'mu4e-hdrs-mode)
 
38
      (let* ((query mu4e-last-expr)
 
39
              desc link)
 
40
        (org-store-link-props :type "mu4e" :query query)
 
41
        (setq
 
42
          desc (org-make-link "mu4e:query:" query)
 
43
          link desc)
 
44
        (org-add-link-props :link link :description desc)
 
45
        link))
 
46
 
 
47
      ;; storing links to messages
 
48
    ((eq major-mode 'mu4e-view-mode)
 
49
      (let* ((msg mu4e-current-msg)
 
50
              (msgid   (or (plist-get msg :message-id) "<none>"))
 
51
              (subject (or (plist-get msg :subject) "No subject"))
 
52
              link)
 
53
        (org-store-link-props :type "mu4e" :link link
 
54
          :message-id msgid :subject subject)
 
55
        (setq link (org-make-link "mu4e:msgid:" msgid))
 
56
        (org-add-link-props :link link :description subject)
 
57
        link))))
 
58
 
 
59
(org-add-link-type "mu4e" 'org-mu4e-open)
 
60
(add-hook 'org-store-link-functions 'org-mu4e-store-link)
 
61
 
 
62
(defun org-mu4e-open (path)
 
63
  "Open the mu4e message (for paths starting with 'msgid:') or run
 
64
the query (for paths starting with 'query:')."
 
65
  (require 'mu4e)
 
66
  (cond
 
67
    ((string-match "^msgid:\\(.+\\)" path)
 
68
      (mu4e-view-message-with-msgid (match-string 1 path)))
 
69
    ((string-match "^query:\\(.+\\)" path)
 
70
      (mu4e-search (match-string 1 path)))
 
71
    (t (message "mu4e: unrecognized link type '%s'" path))))
 
72
 
 
73
 
 
74
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
75
(provide 'org-mu4e)
 
76
 
 
77
;;; org-mu4e.el ends here