[PATCH 3/4] emacs: tree: add sort argument to notmuch-tree

Mark Walters markwalters1009 at gmail.com
Fri Jun 26 15:50:34 PDT 2015


This is used by the the notmuch-search command
notmuch-tree-from-search-current-query which now keeps the sort order
the same when calling tree mode with the current search query.

It also uses the customize variable notmuch-search-oldest-first as the
default for sort order of a tree search (only relevant for interactive
use).
---
 emacs/notmuch-tree.el | 21 +++++++++++++++------
 emacs/notmuch.el      |  2 +-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 6afed76..b9d9b91 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -565,7 +565,9 @@ (defun notmuch-tree-refresh-view ()
     (erase-buffer)
     (notmuch-tree-worker basic-query
 			 query-context
-			 target)))
+			 target
+			 nil
+			 notmuch-tree-oldest-first)))
 
 (defun notmuch-tree-toggle-order ()
   "Toggle the current search order.
@@ -865,7 +867,7 @@ (defun notmuch-tree-process-filter (proc string)
 	(notmuch-sexp-parse-partial-list 'notmuch-tree-insert-forest-thread
 					 results-buf)))))
 
-(defun notmuch-tree-worker (basic-query &optional query-context target open-target)
+(defun notmuch-tree-worker (basic-query &optional query-context target open-target oldest-first)
   "Insert the tree view of the search in the current buffer.
 
 This is is a helper function for notmuch-tree. The arguments are
@@ -876,6 +878,7 @@ (defun notmuch-tree-worker (basic-query &optional query-context target open-targ
   (setq notmuch-tree-query-context query-context)
   (setq notmuch-tree-target-msg target)
   (setq notmuch-tree-open-target open-target)
+  (setq notmuch-tree-oldest-first oldest-first)
 
   (erase-buffer)
   (goto-char (point-min))
@@ -911,7 +914,7 @@ (defun notmuch-tree-get-query ()
 	      ")")
     notmuch-tree-basic-query))
 
-(defun notmuch-tree (&optional query query-context target buffer-name open-target)
+(defun notmuch-tree (&optional query query-context target buffer-name open-target oldest-first)
   "Display threads matching QUERY in Tree View.
 
 The arguments are:
@@ -924,8 +927,14 @@ (defun notmuch-tree (&optional query query-context target buffer-name open-targe
       current if it appears in the tree view results.
   BUFFER-NAME: the name of the buffer to display the tree view. If
       it is nil \"*notmuch-tree\" followed by QUERY is used.
-  OPEN-TARGET: If TRUE open the target message in the message pane."
-  (interactive)
+  OPEN-TARGET: If TRUE open the target message in the message pane.
+  OLDEST-FIRST: If TRUE display threads sorted oldest first"
+  (interactive
+   (list
+    ;; Prompt for a query
+    nil
+    ;; use default search order
+    nil nil nil nil (default-value 'notmuch-search-oldest-first)))
   (if (null query)
       (setq query (notmuch-read-query "Notmuch tree view search: ")))
   (let ((buffer (get-buffer-create (generate-new-buffer-name
@@ -937,7 +946,7 @@ (defun notmuch-tree (&optional query query-context target buffer-name open-targe
   ;; Don't track undo information for this buffer
   (set 'buffer-undo-list t)
 
-  (notmuch-tree-worker query query-context target open-target)
+  (notmuch-tree-worker query query-context target open-target oldest-first)
 
   (setq truncate-lines t))
 
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6564816..f1035dc 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -478,7 +478,7 @@ (defun notmuch-search-show-thread (&optional elide-toggle)
 (defun notmuch-tree-from-search-current-query ()
   "Call notmuch tree with the current query"
   (interactive)
-  (notmuch-tree notmuch-search-query-string))
+  (notmuch-tree notmuch-search-query-string nil nil nil nil notmuch-search-oldest-first))
 
 (defun notmuch-tree-from-search-thread ()
   "Show the selected thread with notmuch-tree"
-- 
2.1.4



More information about the notmuch mailing list