From c5987700e77dbd49bd124b97aa11db6b05c2bafb Mon Sep 17 00:00:00 2001 From: djcb Date: Wed, 10 Dec 2014 22:57:54 -0800 Subject: [PATCH] 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. --- mu4e/mu4e.texi | 10 ++++++---- mu4e/org-mu4e.el | 18 +++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi index 10e20554..c70bdc56 100644 --- a/mu4e/mu4e.texi +++ b/mu4e/mu4e.texi @@ -2684,10 +2684,12 @@ this expects org-mode 8.x. If you have an older version, you can try: @end lisp @noindent -After this, you can use the normal @t{org-mode} mechanisms to store links: -@kbd{M-x org-store-link} stores a link to a particular message when you're -in @ref{Message view}, and a link to a query when you are in @ref{Headers -view}. +After this, you can use the normal @t{org-mode} mechanisms to store +links: @kbd{M-x org-store-link} stores a link to a particular message +when 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{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 @t{org-mode}, you can go to the query or message the link points to with diff --git a/mu4e/org-mu4e.el b/mu4e/org-mu4e.el index 59d722dd..06363d42 100644 --- a/mu4e/org-mu4e.el +++ b/mu4e/org-mu4e.el @@ -13,7 +13,7 @@ ;; ;; 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 -;; 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. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -43,7 +43,11 @@ (defgroup org-mu4e nil "Settings for the org-mode related functionality in 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 (lambda (msg) (or (plist-get msg :subject) "No subject")) @@ -66,9 +70,10 @@ Example usage: (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) + (when (member major-mode '(mu4e-headers-mode mu4e-view-mode)) + (if (and (eq major-mode 'mu4e-headers-mode) + org-mu4e-link-query-in-headers-mode) + ;; storing links to queries (let* ((query (mu4e-last-query)) desc link) (org-store-link-props :type "mu4e" :query query) @@ -76,9 +81,8 @@ Example usage: desc (concat "mu4e:query:" query) link desc) (org-add-link-props :link link :description desc) - link)) + link) ;; storing links to messages - ((eq major-mode 'mu4e-view-mode) (let* ((msg (mu4e-message-at-point)) (msgid (or (plist-get msg :message-id) "")) (from (or (plist-get msg :from) '(("none" . "none"))))