>From 52191a549c5a75495d9e9be864a42c7906bdfdd3 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Tue, 9 Apr 2019 19:15:22 +0200 Subject: [PATCH] ol-notmuch: Make distinct link types for search view and tree view * contrib/lisp/ol-notmuch.el (org-notmuch-search-open-function): Deprecate. (org-notmuch-tree-store-link): New function. (org-notmuch-tree-open): New function. "notmuch-tree": Set new "notmuch-tree" parameters with the above functions. --- contrib/lisp/ol-notmuch.el | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/ol-notmuch.el b/contrib/lisp/ol-notmuch.el index ab4ddacf2..eac8a37ca 100644 --- a/contrib/lisp/ol-notmuch.el +++ b/contrib/lisp/ol-notmuch.el @@ -57,11 +57,14 @@ Should accept a notmuch search string as the sole argument." 'org-notmuch-search-follow-link "Function used to follow notmuch-search links. -Should accept a notmuch search string as the sole argument." +Should accept a notmuch search string as the sole argument. + +This is obsolete and `org-notmuch-search-follow-link' will always be used." :group 'org-notmuch :version "24.4" :package-version '(Org . "8.0") :type 'function) +(make-obsolete-variable 'org-notmuch-search-open-function nil "26.2") ; TODO: What is the right version? @@ -116,7 +119,7 @@ Can link to more than one message, if so all matching messages are shown." (defun org-notmuch-search-open (path) "Follow a notmuch message link specified by PATH." (message "%s" path) - (funcall org-notmuch-search-open-function path)) + (org-notmuch-search-follow-link path)) (defun org-notmuch-search-follow-link (search) "Follow a notmuch link by displaying SEARCH in notmuch-search mode." @@ -125,6 +128,25 @@ Can link to more than one message, if so all matching messages are shown." +(org-link-set-parameters "notmuch-tree" + :follow #'org-notmuch-tree-open + :store #'org-notmuch-tree-store-link) + +(defun org-notmuch-tree-store-link () + "Store a link to a notmuch search or message." + (when (eq major-mode 'notmuch-tree-mode) + (let ((link (concat "notmuch-tree:" (notmuch-tree-get-query))) + (desc (concat "Notmuch tree: " (notmuch-tree-get-query)))) + (org-store-link-props :type "notmuch-tree" + :link link + :description desc) + link))) + +(defun org-notmuch-tree-open (path) + "Follow a notmuch message link specified by PATH." + (message "%s" path) + (org-notmuch-tree-follow-link path)) + (defun org-notmuch-tree-follow-link (search) "Follow a notmuch link by displaying SEARCH in notmuch-tree mode." (require 'notmuch) -- 2.21.0