]> git.notmuchmail.org Git - notmuch/commitdiff
notmuch-hello/jump: allow saved searches to specify unthreaded mode
authorMark Walters <markwalters1009@gmail.com>
Thu, 27 Feb 2020 17:16:52 +0000 (17:16 +0000)
committerDavid Bremner <david@tethera.net>
Fri, 20 Mar 2020 01:08:07 +0000 (22:08 -0300)
Saved searches in notmuch-hello and notmuch-jump can specify whether
to use search mode or tree mode. This adds an option for them to
specify unthreaded mode.

emacs/notmuch-hello.el
emacs/notmuch-jump.el

index 858446dfc9ede21f6849b3e7b633c6306d22ad9a..ab6ee79881f1a18fc3936a29331f04b3de58d5be 100644 (file)
@@ -32,6 +32,9 @@
 (declare-function notmuch-poll "notmuch" ())
 (declare-function notmuch-tree "notmuch-tree"
                  (&optional query query-context target buffer-name open-target unthreaded))
 (declare-function notmuch-poll "notmuch" ())
 (declare-function notmuch-tree "notmuch-tree"
                  (&optional query query-context target buffer-name open-target unthreaded))
+(declare-function notmuch-unthreaded
+                 (&optional query query-context target buffer-name open-target))
+
 
 (defun notmuch-saved-search-get (saved-search field)
   "Get FIELD from SAVED-SEARCH.
 
 (defun notmuch-saved-search-get (saved-search field)
   "Get FIELD from SAVED-SEARCH.
@@ -99,7 +102,8 @@ searches so they still work in customize."
                     (group :format "%v" :inline t (const :format "" :search-type)
                            (choice :tag " Search Type"
                                    (const :tag "Search mode" nil)
                     (group :format "%v" :inline t (const :format "" :search-type)
                            (choice :tag " Search Type"
                                    (const :tag "Search mode" nil)
-                                   (const :tag "Tree mode" tree))))))
+                                   (const :tag "Tree mode" tree)
+                                   (const :tag "Unthreaded mode" unthreaded))))))
 
 (defcustom notmuch-saved-searches
   `((:name "inbox" :query "tag:inbox" :key ,(kbd "i"))
 
 (defcustom notmuch-saved-searches
   `((:name "inbox" :query "tag:inbox" :key ,(kbd "i"))
@@ -122,10 +126,10 @@ a plist. Supported properties are
   :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.
   :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.
-  :search-type     Specify whether to run the search in search-mode
-                   or tree mode. Set to 'tree to specify tree
-                   mode, set to nil (or anything except tree) to
-                   specify search mode.
+  :search-type     Specify whether to run the search in search-mode,
+                   tree mode or unthreaded mode. Set to 'tree to specify tree
+                   mode, 'unthreaded to specify unthreaded mode, and set to nil
+                   (or anything except tree and unthreaded) to specify search mode.
 
 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)."
@@ -437,13 +441,18 @@ diagonal."
          append (notmuch-hello-reflect-generate-row ncols nrows row list))))
 
 (defun notmuch-hello-widget-search (widget &rest ignore)
          append (notmuch-hello-reflect-generate-row ncols nrows row list))))
 
 (defun notmuch-hello-widget-search (widget &rest ignore)
-  (if (widget-get widget :notmuch-search-type)
-      (notmuch-tree (widget-get widget
-                               :notmuch-search-terms))
+  (cond
+   ((eq (widget-get widget :notmuch-search-type) 'tree)
+    (notmuch-tree (widget-get widget
+                             :notmuch-search-terms)))
+   ((eq (widget-get widget :notmuch-search-type) 'unthreaded)
+    (notmuch-unthreaded (widget-get widget
+                                   :notmuch-search-terms)))
+   (t
     (notmuch-search (widget-get widget
                                :notmuch-search-terms)
                    (widget-get widget
     (notmuch-search (widget-get widget
                                :notmuch-search-terms)
                    (widget-get widget
-                               :notmuch-search-oldest-first))))
+                               :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)))
@@ -579,7 +588,7 @@ with `notmuch-hello-query-counts'."
                                     (newest-first nil)
                                     (oldest-first t)
                                     (otherwise notmuch-search-oldest-first)))
                                     (newest-first nil)
                                     (oldest-first t)
                                     (otherwise notmuch-search-oldest-first)))
-                    (search-type (eq (plist-get elem :search-type) 'tree))
+                    (search-type (plist-get elem :search-type))
                     (msg-count (plist-get elem :count)))
                (widget-insert (format "%8s "
                                       (notmuch-hello-nice-number msg-count)))
                     (msg-count (plist-get elem :count)))
                (widget-insert (format "%8s "
                                       (notmuch-hello-nice-number msg-count)))
index 3e20b8c7afc68e6b9d56a709ecc74283b173ae38..1cdf5b5090d7cb594f29338e3eb98cb56f64ceb1 100644 (file)
@@ -56,9 +56,13 @@ fast way to jump to a saved search from anywhere in Notmuch."
                   (oldest-first t)
                   (otherwise (default-value 'notmuch-search-oldest-first)))))
            (push (list key name
                   (oldest-first t)
                   (otherwise (default-value 'notmuch-search-oldest-first)))))
            (push (list key name
-                       (if (eq (plist-get saved-search :search-type) 'tree)
-                           `(lambda () (notmuch-tree ',query))
-                         `(lambda () (notmuch-search ',query ',oldest-first))))
+                       (cond
+                        ((eq (plist-get saved-search :search-type) 'tree)
+                         `(lambda () (notmuch-tree ',query)))
+                        ((eq (plist-get saved-search :search-type) 'unthreaded)
+                         `(lambda () (notmuch-unthreaded ',query)))
+                        (t
+                         `(lambda () (notmuch-search ',query ',oldest-first)))))
                  action-map)))))
     (setq action-map (nreverse action-map))
 
                  action-map)))))
     (setq action-map (nreverse action-map))