gpt4 book ai didi

emacs - 在 mu4e 中使用 org-capture-templates

转载 作者:行者123 更新时间:2023-12-04 15:23:43 26 4
gpt4 key购买 nike

我正在尝试在使用 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)

最佳答案

这样的事情应该工作:

(setq from
(let ((first (car (mu4e-message-field-at-point :from))))
(if (car first)
(format "%s <%s>" (car first) (cdr first))
(cdr first))))

关于emacs - 在 mu4e 中使用 org-capture-templates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17254967/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com