[PATCH 5/5] emacs: Add a sort-order option to saved-searches

Mark Walters markwalters1009 at gmail.com
Sat Apr 5 14:24:25 PDT 2014


This adds a sort-order option to saved-searches, stores it in the
saved-search buttons (widgets), and uses the stored value when the
button is pressed.

Storing the sort-order in the widget was suggested by Jani in
id:4c3876274126985683e888641b29cf18142a5eb8.1391771337.git.jani at nikula.org.
---
 emacs/notmuch-hello.el |   11 ++++++++++-
 emacs/notmuch-lib.el   |    7 ++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index aa40e6f..6a28372 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -364,7 +364,8 @@ (defun notmuch-hello-reflect (list ncols)
 (defun notmuch-hello-widget-search (widget &rest ignore)
   (notmuch-search (widget-get widget
 			      :notmuch-search-terms)
-		  notmuch-search-oldest-first))
+		  (widget-get widget
+			      :notmuch-search-oldest-first)))
 
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command "count" search)))
@@ -496,12 +497,20 @@ (defun notmuch-hello-insert-buttons (searches)
 		  (widget-insert (make-string column-indent ? )))
 	      (let* ((name (plist-get elem :name))
 		     (query (plist-get elem :query))
+		     (oldest-first (cond
+				    ((eq (plist-get elem :sort-order) 'newest-first)
+				     nil)
+				    ((eq (plist-get elem :sort-order) 'oldest-first)
+				     t)
+				    (t
+				     notmuch-search-oldest-first)))
 		     (msg-count (plist-get elem :count)))
 		(widget-insert (format "%8s "
 				       (notmuch-hello-nice-number msg-count)))
 		(widget-create 'push-button
 			       :notify #'notmuch-hello-widget-search
 			       :notmuch-search-terms query
+			       :notmuch-search-oldest-first oldest-first
 			       name)
 		(setq column-indent
 		      (1+ (max 0 (- column-width (length name)))))))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 8a12f91..8aa8cfc 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -125,7 +125,12 @@ (define-widget 'notmuch-saved-search-plist 'list
 		(group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))
 	  (checklist :inline t
 		     :format "%v"
-		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v")))))
+		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))
+		     (group :format "%v" :inline t (const :format "" :sort-order)
+			    (choice :tag " Sort Order"
+				    (const :tag "Default" nil)
+				    (const :tag "Oldest-first" oldest-first)
+				    (const :tag "Newest-first" newest-first))))))
 
 (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
 				    (:name "unread" :query "tag:unread"))
-- 
1.7.10.4



More information about the notmuch mailing list