mirror of https://github.com/djcb/mu.git
added org-mu4e-link-desc-func
Replaces org-mu4e-link-description, a customisable function is nicer than a string.
This commit is contained in:
parent
fdbc20f04b
commit
143b0b0ff4
|
@ -36,12 +36,26 @@
|
||||||
"Settings for the org interface."
|
"Settings for the org interface."
|
||||||
:group 'org-mu4e)
|
:group 'org-mu4e)
|
||||||
|
|
||||||
(defcustom org-mu4e-link-description 'subject
|
(defcustom org-mu4e-link-desc-func (lambda (msg)
|
||||||
"How to make the org-mode link description."
|
(or (plist-get msg :subject)
|
||||||
:type 'string
|
"No subject"))
|
||||||
:group 'org-mu4e)
|
"Function that takes a msg and returns a string for the
|
||||||
|
description part of an org-mode link.
|
||||||
|
|
||||||
;;(setq org-mu4e-link-description '(concat date " " subject))
|
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 ()
|
(defun org-mu4e-store-link ()
|
||||||
"Store a link to a mu4e query or message."
|
"Store a link to a mu4e query or message."
|
||||||
|
@ -60,18 +74,14 @@
|
||||||
;; storing links to messages
|
;; storing links to messages
|
||||||
((eq major-mode 'mu4e-view-mode)
|
((eq major-mode 'mu4e-view-mode)
|
||||||
(let* ((msg (mu4e-message-at-point))
|
(let* ((msg (mu4e-message-at-point))
|
||||||
(msgid (or (plist-get msg :message-id) "<none>"))
|
(msgid (or (plist-get msg :message-id) "<none>"))
|
||||||
(subject (or (plist-get msg :subject) "No subject"))
|
link)
|
||||||
(date (or (format-time-string mu4e-headers-date-format
|
(org-store-link-props :type "mu4e" :link link
|
||||||
(mu4e-msg-field msg :date))
|
:message-id msgid)
|
||||||
"No date"))
|
(setq link (org-make-link "mu4e:msgid:" msgid))
|
||||||
link)
|
(org-add-link-props :link link
|
||||||
(org-store-link-props :type "mu4e" :link link
|
:description (funcall org-mu4e-link-desc-func msg))
|
||||||
:message-id msgid :subject subject :date date)
|
link))))
|
||||||
(setq link (org-make-link "mu4e:msgid:" msgid))
|
|
||||||
(org-add-link-props :link link
|
|
||||||
:description (eval org-mu4e-link-description))
|
|
||||||
link))))
|
|
||||||
|
|
||||||
(org-add-link-type "mu4e" 'org-mu4e-open)
|
(org-add-link-type "mu4e" 'org-mu4e-open)
|
||||||
(add-hook 'org-store-link-functions 'org-mu4e-store-link)
|
(add-hook 'org-store-link-functions 'org-mu4e-store-link)
|
||||||
|
|
Loading…
Reference in New Issue