From 74ab62a34018b38a40db4d363fff3faae964b47a Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 2 Jul 2021 21:44:22 +0100 Subject: [PATCH] emacs/hello: honouring :sort-order in threaded queries Now that notmuch show accepts --sort, we can, on the emacs side, use it according to the value of :sort-order in the definition of saved queries. --- emacs/notmuch-hello.el | 4 +++- emacs/notmuch-tree.el | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 531f209d..5e1ff5fe 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -484,7 +484,9 @@ diagonal." (defun notmuch-hello-widget-search (widget &rest _ignore) (cl-case (widget-get widget :notmuch-search-type) (tree - (notmuch-tree (widget-get widget :notmuch-search-terms))) + (notmuch-tree (widget-get widget :notmuch-search-terms) + nil nil nil nil nil nil + (widget-get widget :notmuch-search-oldest-first))) (unthreaded (notmuch-unthreaded (widget-get widget :notmuch-search-terms))) (t diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 56863701..49d7659e 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -1064,7 +1064,8 @@ Complete list of currently available key bindings: (notmuch-sexp-parse-partial-list 'notmuch-tree-insert-forest-thread results-buf))))) -(defun notmuch-tree-worker (basic-query &optional query-context target open-target unthreaded) +(defun notmuch-tree-worker (basic-query &optional query-context target + open-target unthreaded 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 @@ -1090,6 +1091,7 @@ the same as for the function notmuch-tree." (let* ((search-args (concat basic-query (and query-context (concat " and (" query-context ")")))) + (sort-arg (if oldest-first "--sort=oldest-first" "--sort=newest-first")) (message-arg (if unthreaded "--unthreaded" "--entire-thread"))) (when (equal (car (process-lines notmuch-command "count" search-args)) "0") (setq search-args basic-query)) @@ -1097,7 +1099,7 @@ the same as for the function notmuch-tree." (let ((proc (notmuch-start-notmuch "notmuch-tree" (current-buffer) #'notmuch-tree-process-sentinel "show" "--body=false" "--format=sexp" "--format-version=4" - message-arg search-args)) + sort-arg message-arg search-args)) ;; Use a scratch buffer to accumulate partial output. ;; This buffer will be killed by the sentinel, which ;; should be called no matter how the process dies. @@ -1116,7 +1118,7 @@ the same as for the function notmuch-tree." notmuch-tree-basic-query)) (defun notmuch-tree (&optional query query-context target buffer-name - open-target unthreaded parent-buffer) + open-target unthreaded parent-buffer oldest-first) "Display threads matching QUERY in tree view. The arguments are: @@ -1145,7 +1147,7 @@ The arguments are: (pop-to-buffer-same-window buffer)) ;; Don't track undo information for this buffer (setq buffer-undo-list t) - (notmuch-tree-worker query query-context target open-target unthreaded) + (notmuch-tree-worker query query-context target open-target unthreaded oldest-first) (setq notmuch-tree-parent-buffer parent-buffer) (setq truncate-lines t)) -- 2.43.0