summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2021-08-09 07:58:31 +0300
committerGitHub <noreply@github.com>2021-08-09 07:58:31 +0300
commitc29368af930461a4ad8fc62b99c0f49cb8fcf330 (patch)
tree942d5f0b0e05ac42d87916b8dfb4eff65117c924
parentaa75487ae64a70b580c3d8a338adc75e1e8a4b3f (diff)
parentf6230467dcda324d7141761bc6142e228dc42d7a (diff)
Merge pull request #2081 from danielfleischer/link-description
Customize the mu4e org link description
-rw-r--r--mu4e/mu4e-org.el21
-rw-r--r--mu4e/mu4e.texi3
2 files changed, 22 insertions, 2 deletions
diff --git a/mu4e/mu4e-org.el b/mu4e/mu4e-org.el
index a0ac09f..7f20573 100644
--- a/mu4e/mu4e-org.el
+++ b/mu4e/mu4e-org.el
@@ -36,6 +36,25 @@
:group 'mu4e
:group 'org)
+(defcustom mu4e-org-link-desc-func
+ (lambda (msg) (or (plist-get msg :subject) "No subject"))
+ "Function that takes a msg and returns a description.
+This can be used in org capture templates and storing links.
+
+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 'mu4e-org)
+
(defvar mu4e-org-link-query-in-headers-mode nil
"Prefer linking to the query rather than to the message.
If non-nil, `org-store-link' in `mu4e-headers-mode' links to the
@@ -79,7 +98,7 @@ the current query; otherwise, it links to the message at point.")
:to (when to
(mu4e~org-address to))
:link (concat "mu4e:msgid:" msgid)
- :description (or (plist-get msg :subject) "No subject"))))
+ :description (funcall mu4e-org-link-desc-func msg))))
(defun mu4e-org-store-link ()
"Store a link to a mu4e message or query.
diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi
index 75dc242..9d27719 100644
--- a/mu4e/mu4e.texi
+++ b/mu4e/mu4e.texi
@@ -3544,7 +3544,8 @@ You can use the normal @t{org-mode} mechanisms to store links:
you are in @ref{Message view}. When you are in @ref{Headers view},
@kbd{M-x org-store-link} links to the @emph{query} if
@code{mu4e-org-link-query-in-headers-mode} is non-@code{nil}, and to
-the particular message otherwise (which is the default).
+the particular message otherwise (which is the default). You can
+customize the link description using @code{mu4e-org-link-desc-func}.
You can insert this link later with @kbd{M-x org-insert-link}. From
@t{org-mode}, you can go to the query or message the link points to