]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Add a sort-order option to saved-searches
authorMark Walters <markwalters1009@gmail.com>
Sun, 6 Apr 2014 05:44:49 +0000 (06:44 +0100)
committerDavid Bremner <david@tethera.net>
Fri, 11 Apr 2014 13:27:26 +0000 (10:27 -0300)
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@nikula.org.

emacs/notmuch-hello.el
emacs/notmuch-lib.el

index e2b6ce4f77f77e8f7ae7aaa9bd93d6eb6bb78294..4900a242242aa2e0a5aa9040a01b85d84492fc95 100644 (file)
@@ -363,7 +363,8 @@ diagonal."
 (defun notmuch-hello-widget-search (widget &rest ignore)
   (notmuch-search (widget-get widget
                              :notmuch-search-terms)
 (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)))
 
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command "count" search)))
@@ -495,12 +496,17 @@ with `notmuch-hello-query-counts'."
                  (widget-insert (make-string column-indent ? )))
              (let* ((name (plist-get elem :name))
                     (query (plist-get elem :query))
                  (widget-insert (make-string column-indent ? )))
              (let* ((name (plist-get elem :name))
                     (query (plist-get elem :query))
+                    (oldest-first (case (plist-get elem :sort-order)
+                                    (newest-first nil)
+                                    (oldest-first t)
+                                    (otherwise 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
                     (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)))))))
                               name)
                (setq column-indent
                      (1+ (max 0 (- column-width (length name)))))))
index a54a055e6f32f5fee3511f02da1d37df8340e935..3a3c69d312e3dc00981ba471e400e47f65ec1fcb 100644 (file)
@@ -125,7 +125,12 @@ searches so they still work in customize."
                (group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))
          (checklist :inline t
                     :format "%v"
                (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"))
 
 (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
                                    (:name "unread" :query "tag:unread"))
@@ -139,6 +144,9 @@ a plist. Supported properties are
   :count-query     Optional extra query to generate the count
                    shown. If not present then the :query property
                    is used.
   :count-query     Optional extra query to generate the count
                    shown. If not present then the :query property
                    is used.
+  :sort-order      Specify the sort order to be used for the search.
+                   Possible values are 'oldest-first 'newest-first or
+                   nil. Nil means use the default sort order.
 
 Other accepted forms are a cons cell of the form (NAME . QUERY)
 or a list of the form (NAME QUERY COUNT-QUERY)."
 
 Other accepted forms are a cons cell of the form (NAME . QUERY)
 or a list of the form (NAME QUERY COUNT-QUERY)."