Merge pull request #39 from mylese/org-mu4e-link-description

* make the org-mu4e links user-customizable
This commit is contained in:
Dirk-Jan C. Binnema 2012-08-01 10:49:06 -07:00
commit da098f2dee
1 changed files with 33 additions and 8 deletions

View File

@ -32,6 +32,31 @@
(eval-when-compile (require 'cl))
(eval-when-compile (require 'mu4e))
(defgroup org-mu4e nil
"Settings for the org interface."
:group 'org-mu4e)
(defcustom org-mu4e-link-desc-func (lambda (msg)
(or (plist-get msg :subject)
"No subject"))
"Function that takes a msg and returns a string for the
description part of an org-mode link.
Example usage:
(defun my-link-descr (msg)
(let
((subject (or (plist-get msg :subject)
\"No subject\"))
(date (or (format-time-string mu4e-headers-date-format
(mu4e-msg-field msg :date))
\"No date\")))
(concat subject \" \" date)))
(setq org-mu4e-link-desc-func 'my-link-descr)"
:type 'function
:group 'org-mu4e)
(defun org-mu4e-store-link ()
"Store a link to a mu4e query or message."
(cond
@ -49,14 +74,14 @@
;; storing links to messages
((eq major-mode 'mu4e-view-mode)
(let* ((msg (mu4e-message-at-point))
(msgid (or (plist-get msg :message-id) "<none>"))
(subject (or (plist-get msg :subject) "No subject"))
link)
(org-store-link-props :type "mu4e" :link link
:message-id msgid :subject subject)
(setq link (org-make-link "mu4e:msgid:" msgid))
(org-add-link-props :link link :description subject)
link))))
(msgid (or (plist-get msg :message-id) "<none>"))
link)
(org-store-link-props :type "mu4e" :link link
:message-id msgid)
(setq link (org-make-link "mu4e:msgid:" msgid))
(org-add-link-props :link link
:description (funcall org-mu4e-link-desc-func msg))
link))))
(org-add-link-type "mu4e" 'org-mu4e-open)
(add-hook 'org-store-link-functions 'org-mu4e-store-link)