在使用mu4e时,我正在尝试使用org-capture模板创建模板。在mu4e:view模式下查看消息时,我可以通过按键调用org-capture-templates,然后在文件中添加提醒,并在其中添加指向消息的链接。像这样:
* 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
这是我的.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))))
但是orgmode官方手册第9.1.3.2节中的变量未在mu4e中设置。我的猜测是它应该在org-mu4e.el中的以下函数中设置。请参阅我添加的评论标记的3行,但这并不能解决问题。链接(%a)被初始化,但不是:to,:from和:subject。
如果我调试,我可以看到对org-store-link-props的函数调用如下所示:
org-store-link-props(:type "mu4e" :from (("Person Name" . "person@email.whatever"))
:to (("Me Surname" . "me@here.com")) :subject "Re: Subject of Email"
:message-id "message-id")
但是,模板的评估结果为:
* NEXT Respond to %:from on %:subject
SCHEDULED: <2013-06-23 Sun>
[2013-06-23 Sun 21:08]
感谢您的帮助 - 这是对我有用的最终功能:
(defun org-mu4e-store-link ()
"Store a link to a mu4e query or 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))))
(to (car (car (mu4e-message-field msg :to))))
(subject (mu4e-message-field msg :subject))
link)
(setq link (concat "mu4e:msgid:" msgid))
(org-store-link-props :type "mu4e" :link link
:message-id msgid)
(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))))
(org-add-link-type "mu4e" 'org-mu4e-open)
(add-hook 'org-store-link-functions 'org-mu4e-store-link)
答案 0 :(得分:4)
这样的事情应该有效:
(setq from
(let ((first (car (mu4e-message-field-at-point :from))))
(if (car first)
(format "%s <%s>" (car first) (cdr first))
(cdr first))))