Hi everybody,
I'm trying to create a template using org-capture templates when using mu4e. When viewing a message in mu4e:view mode, I can call org-capture-templates with a keystroke and then add a reminder in a file with a link to the message. Something like this:
* NEXT Respond to Person A on Message Subject
SCHEDULED: <2013-06-22 Sat>
[2013-06-22 Sat 22:05]
Email subject linked to mu4e message
Here's the template in my .emacs:
(setq org-capture-templates
(quote (("r" "respond" entry (file "~/refile.org")
"* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n\n"
:clock-in t :clock-resume t :immediate-finish t))))
But the variables in section 9.1.3.2 of the org-mode official manual
are not set in mu4e. I got it working by editing the following
function in org-mu4e.el. See the lines marked by a comment I added. It is a halfhearted and ugly attempt to fix the problem. Maybe somebody can help to make it more generic and elegant.
(defun org-mu4e-store-link ()
"Store a link to a mu4e query xor message."
(cond
;; storing links to queries
((eq major-mode 'mu4e-headers-mode)
(let* ((query (mu4e-last-query))
desc link)
(org-store-link-props :type "mu4e" :query query)
(setq
desc (concat "mu4e:query:" query)
link desc)
(org-add-link-props :link link :description desc)
link))
;; storing links to messages
((eq major-mode 'mu4e-view-mode)
(let* ((msg (mu4e-message-at-point))
(msgid (or (plist-get msg :message-id) "<none>"))
(from (car (car (mu4e-message-field msg :from)))) ;; edited
(to (car (car (mu4e-message-field msg :to)))) ;; edited
(subject (mu4e-message-field msg :subject)) ;; edited
link)
(setq link (concat "mu4e:msgid:" msgid))
(org-store-link-props
:type "mu4e" :from from :to to :subject subject
:message-id msgid)
(org-add-link-props :link link
:description (funcall org-mu4e-link-desc-func msg))
link))))