mu4e: org: allow customization of linking in headers mode

Depending on org-mu4e-link-query-in-headers-mode, we can link to the
query or the particular message.
This commit is contained in:
djcb
2014-12-10 22:57:54 -08:00
parent 9162e3e68c
commit c5987700e7
2 changed files with 17 additions and 11 deletions

View File

@ -2684,10 +2684,12 @@ this expects org-mode 8.x. If you have an older version, you can try:
@end lisp @end lisp
@noindent @noindent
After this, you can use the normal @t{org-mode} mechanisms to store links: After this, you can use the normal @t{org-mode} mechanisms to store
@kbd{M-x org-store-link} stores a link to a particular message when you're links: @kbd{M-x org-store-link} stores a link to a particular message
in @ref{Message view}, and a link to a query when you are in @ref{Headers when you are in @ref{Message view}. When you are in @ref{Headers view},
view}. @kbd{M-x org-store-link} links to the @emph{query} if
@code{org-mu4e-link-query-in-headers-mode} is non-@code{nil}, and to the
particular message otherwise.
You can insert this link later with @kbd{M-x org-insert-link}. From 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 with @t{org-mode}, you can go to the query or message the link points to with

View File

@ -13,7 +13,7 @@
;; ;;
;; GNU Emacs is free software: you can redistribute it and/or modify ;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by ;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or ;; the Free Software Foundation, either version 3 of 1the License, or
;; (at your option) any later version. ;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful, ;; GNU Emacs is distributed in the hope that it will be useful,
@ -43,7 +43,11 @@
(defgroup org-mu4e nil (defgroup org-mu4e nil
"Settings for the org-mode related functionality in mu4e." "Settings for the org-mode related functionality in mu4e."
:group 'mu4e :group 'mu4e
:group 'org) :group 'org)
(defvar org-mu4e-link-query-in-headers-mode t
"If non-nil, `org-store-link' in `mu4e-headers-mode' links to the
the current query; otherwise, it links to the message at point.")
(defcustom org-mu4e-link-desc-func (defcustom org-mu4e-link-desc-func
(lambda (msg) (or (plist-get msg :subject) "No subject")) (lambda (msg) (or (plist-get msg :subject) "No subject"))
@ -66,9 +70,10 @@ Example usage:
(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."
(cond (when (member major-mode '(mu4e-headers-mode mu4e-view-mode))
;; storing links to queries (if (and (eq major-mode 'mu4e-headers-mode)
((eq major-mode 'mu4e-headers-mode) org-mu4e-link-query-in-headers-mode)
;; storing links to queries
(let* ((query (mu4e-last-query)) (let* ((query (mu4e-last-query))
desc link) desc link)
(org-store-link-props :type "mu4e" :query query) (org-store-link-props :type "mu4e" :query query)
@ -76,9 +81,8 @@ Example usage:
desc (concat "mu4e:query:" query) desc (concat "mu4e:query:" query)
link desc) link desc)
(org-add-link-props :link link :description desc) (org-add-link-props :link link :description desc)
link)) link)
;; storing links to messages ;; storing links to messages
((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>"))
(from (or (plist-get msg :from) '(("none" . "none")))) (from (or (plist-get msg :from) '(("none" . "none"))))