unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/4] Allow oldest-first view in tree view
@ 2015-06-26 22:50 Mark Walters
  2015-06-26 22:50 ` [PATCH 1/4] cli: show: allow sort order to be specified Mark Walters
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Mark Walters @ 2015-06-26 22:50 UTC (permalink / raw)
  To: notmuch

This series allows the user to toggle the sort order in tree view and,
in particular, allows oldest first view.

Note that in all cases messages within a thread are displayed in
thread order: the option only affects the order when multiple threads
are viewed. If you only use tree view for single threads then nothing
will change.

Since tree view uses the notmuch-show command line as a backend this
means we need to add a --sort option tonotmuch show. This is the first
patch.

The second patch implements the toggle sort order option bound to 'o'
(so the same as the corresponding command in search view).

These third and fourth patches are more optional: they make notmuch
tree view inherit the notmuch search order when called via Z
(notmuch-tree-from-search-current-query), and use the default
notmuch-search sort order (notmuch-search-oldest-first) when called
interactively. The third patch does the code change and the fourth the
test update.

I think these last two patches make sense for consistency but I have
no strong feelings otherwise.

Best wishes

Mark




Mark Walters (4):
  cli: show: allow sort order to be specified
  emacs: tree: bind o to toggle sort order
  emacs: tree: add sort argument to notmuch-tree
  test: tree: fix and a test for tree sort order changes

 doc/man1/notmuch-show.rst                          | 17 +++++++
 emacs/notmuch-tree.el                              | 44 +++++++++++++++---
 emacs/notmuch.el                                   |  2 +-
 notmuch-show.c                                     |  8 ++++
 test/T460-emacs-tree.sh                            | 11 ++++-
 .../notmuch-tree-tag-inbox-oldest-first            | 53 ++++++++++++++++++++++
 6 files changed, 126 insertions(+), 9 deletions(-)
 create mode 100644 test/tree.expected-output/notmuch-tree-tag-inbox-oldest-first

-- 
2.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] cli: show: allow sort order to be specified
  2015-06-26 22:50 [PATCH 0/4] Allow oldest-first view in tree view Mark Walters
@ 2015-06-26 22:50 ` Mark Walters
  2015-07-31 19:11   ` David Bremner
  2015-06-26 22:50 ` [PATCH 2/4] emacs: tree: bind o to toggle sort order Mark Walters
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Mark Walters @ 2015-06-26 22:50 UTC (permalink / raw)
  To: notmuch

This allows the sort to be specified in the notmuch show command with
a --sort option.

Note that individual threads are still displayed in oldest first
order, but if the search has multiple threads then these are ordered
according to this option. This should mean that most callers won't
notice the option (e.g. the emacs show mode) as they only call show on
individual threads, but other users, particularly the emacs tree view,
can use it.
---
 doc/man1/notmuch-show.rst | 17 +++++++++++++++++
 notmuch-show.c            |  8 ++++++++
 2 files changed, 25 insertions(+)

diff --git a/doc/man1/notmuch-show.rst b/doc/man1/notmuch-show.rst
index 9eb5198..7717b08 100644
--- a/doc/man1/notmuch-show.rst
+++ b/doc/man1/notmuch-show.rst
@@ -97,6 +97,23 @@ Supported options for **show** include
         intended for programs that invoke **notmuch(1)** internally. If
         omitted, the latest supported version will be used.
 
+    ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)
+        This option can be used to present results in either
+        chronological order (**oldest-first**) or reverse chronological
+        order (**newest-first**).
+
+        Note: This only affects the order of messages in different
+        threads: messages inside a thread will always be presented in
+        thread order.  However, the order of the threads will be distinct
+        between these two options (beyond being simply reversed). When
+        sorting by **oldest-first** the threads will be sorted by the
+        oldest message in each thread, but when sorting by
+        **newest-first** the threads will be sorted by the newest
+        message in each thread.
+
+        By default, results will be displayed in reverse chronological
+        order, (that is, the newest results will be displayed first).
+
     ``--part=N``
         Output the single decoded MIME part N of a single message. The
         search terms must match only a single message. Message parts are
diff --git a/notmuch-show.c b/notmuch-show.c
index b80933a..ec9a915 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1090,6 +1090,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
     int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
     int exclude = EXCLUDE_TRUE;
     int entire_thread = ENTIRE_THREAD_DEFAULT;
+    notmuch_sort_t sort = NOTMUCH_SORT_NEWEST_FIRST;
 
     notmuch_opt_desc_t options[] = {
 	{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
@@ -1100,10 +1101,15 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
 				  { "raw", NOTMUCH_FORMAT_RAW },
 				  { 0, 0 } } },
 	{ NOTMUCH_OPT_INT, &notmuch_format_version, "format-version", 0, 0 },
+	{ NOTMUCH_OPT_KEYWORD, &sort, "sort", 's',
+	  (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
+				  { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
+				  { 0, 0 } } },
 	{ NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',
 	  (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
 				  { "false", EXCLUDE_FALSE },
 				  { 0, 0 } } },
+
 	{ NOTMUCH_OPT_KEYWORD, &entire_thread, "entire-thread", 't',
 	  (notmuch_keyword_t []){ { "true", ENTIRE_THREAD_TRUE },
 				  { "false", ENTIRE_THREAD_FALSE },
@@ -1233,6 +1239,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
 	size_t search_exclude_tags_length;
 	unsigned int i;
 
+	notmuch_query_set_sort (query, sort);
+
 	search_exclude_tags = notmuch_config_get_search_exclude_tags
 	    (config, &search_exclude_tags_length);
 	for (i = 0; i < search_exclude_tags_length; i++)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] emacs: tree: bind o to toggle sort order
  2015-06-26 22:50 [PATCH 0/4] Allow oldest-first view in tree view Mark Walters
  2015-06-26 22:50 ` [PATCH 1/4] cli: show: allow sort order to be specified Mark Walters
@ 2015-06-26 22:50 ` Mark Walters
  2015-07-31 19:39   ` David Bremner
  2015-06-26 22:50 ` [PATCH 3/4] emacs: tree: add sort argument to notmuch-tree Mark Walters
  2015-06-26 22:50 ` [PATCH 4/4] test: tree: fix and a test for tree sort order changes Mark Walters
  3 siblings, 1 reply; 8+ messages in thread
From: Mark Walters @ 2015-06-26 22:50 UTC (permalink / raw)
  To: notmuch

---
 emacs/notmuch-tree.el | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 8b6cd51..6afed76 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -194,6 +194,10 @@ (defvar notmuch-tree-message-buffer nil
 (make-variable-buffer-local 'notmuch-tree-message-buffer)
 (put 'notmuch-tree-message-buffer 'permanent-local t)
 
+(defvar notmuch-tree-oldest-first nil
+  "Controls whether to sort oldest-first or not")
+(make-variable-buffer-local 'notmuch-tree-oldest-first)
+
 (defun notmuch-tree-to-message-pane (func)
   "Execute FUNC in message pane.
 
@@ -265,6 +269,7 @@ (defvar notmuch-tree-mode-map
     (define-key map "A" 'notmuch-tree-archive-thread)
     (define-key map "a" 'notmuch-tree-archive-message-then-next)
     (define-key map "=" 'notmuch-tree-refresh-view)
+    (define-key map "o" 'notmuch-tree-toggle-order)
     (define-key map "z" 'notmuch-tree-to-tree)
     (define-key map "n" 'notmuch-tree-next-matching-message)
     (define-key map "p" 'notmuch-tree-prev-matching-message)
@@ -562,6 +567,18 @@ (defun notmuch-tree-refresh-view ()
 			 query-context
 			 target)))
 
+(defun notmuch-tree-toggle-order ()
+  "Toggle the current search order.
+
+By default, the threads in `notmuch-tree' are displayed
+reverse-chronological order (newest thread at the beginning of
+the buffer).
+
+This command toggles the sort order for the current search."
+  (interactive)
+  (setq notmuch-tree-oldest-first (not notmuch-tree-oldest-first))
+  (notmuch-tree-refresh-view))
+
 (defun notmuch-tree-thread-top ()
   (when (notmuch-tree-get-message-properties)
     (while (not (or (notmuch-tree-get-prop :first) (eobp)))
@@ -872,7 +889,11 @@ (defun notmuch-tree-worker (basic-query &optional query-context target open-targ
     (let ((proc (notmuch-start-notmuch
 		 "notmuch-tree" (current-buffer) #'notmuch-tree-process-sentinel
 		 "show" "--body=false" "--format=sexp"
-		 message-arg search-args))
+		 message-arg
+		 (if oldest-first
+			 "--sort=oldest-first"
+		       "--sort=newest-first")
+		 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.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] emacs: tree: add sort argument to notmuch-tree
  2015-06-26 22:50 [PATCH 0/4] Allow oldest-first view in tree view Mark Walters
  2015-06-26 22:50 ` [PATCH 1/4] cli: show: allow sort order to be specified Mark Walters
  2015-06-26 22:50 ` [PATCH 2/4] emacs: tree: bind o to toggle sort order Mark Walters
@ 2015-06-26 22:50 ` Mark Walters
  2015-08-01  5:49   ` David Bremner
  2015-06-26 22:50 ` [PATCH 4/4] test: tree: fix and a test for tree sort order changes Mark Walters
  3 siblings, 1 reply; 8+ messages in thread
From: Mark Walters @ 2015-06-26 22:50 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] test: tree: fix and a test for tree sort order changes
  2015-06-26 22:50 [PATCH 0/4] Allow oldest-first view in tree view Mark Walters
                   ` (2 preceding siblings ...)
  2015-06-26 22:50 ` [PATCH 3/4] emacs: tree: add sort argument to notmuch-tree Mark Walters
@ 2015-06-26 22:50 ` Mark Walters
  3 siblings, 0 replies; 8+ messages in thread
From: Mark Walters @ 2015-06-26 22:50 UTC (permalink / raw)
  To: notmuch

We add a sort order test for tree view. Also, since tree-view inherits
the sort order from search view when called with
notmuch-tree-from-search-current-query one of the tests coming from
search now has oldest-first sort order so update it appropriately.
---
 test/T460-emacs-tree.sh                            | 11 ++++-
 .../notmuch-tree-tag-inbox-oldest-first            | 53 ++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)
 create mode 100644 test/tree.expected-output/notmuch-tree-tag-inbox-oldest-first

diff --git a/test/T460-emacs-tree.sh b/test/T460-emacs-tree.sh
index 8e9f37c..ae075c5 100755
--- a/test/T460-emacs-tree.sh
+++ b/test/T460-emacs-tree.sh
@@ -23,6 +23,15 @@ test_emacs '(notmuch-tree "tag:inbox")
 	    (delete-other-windows)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
 
+test_begin_subtest "Oldest first notmuch-tree view in emacs"
+test_emacs '(notmuch-tree "tag:inbox")
+	    (notmuch-test-wait)
+	    (notmuch-tree-toggle-order)
+	    (notmuch-test-wait)
+	    (test-output)
+	    (delete-other-windows)'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox-oldest-first
+
 # In the following tag tests we make sure the display is updated
 # correctly and, in a separate test, that the database is updated
 # correctly.
@@ -98,7 +107,7 @@ test_emacs '(notmuch-hello)
 	    (notmuch-test-wait)
 	    (test-output)
 	    (delete-other-windows)'
-test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox-oldest-first
 
 test_begin_subtest "Tree view of a single thread (from search)"
 test_emacs '(notmuch-hello)
diff --git a/test/tree.expected-output/notmuch-tree-tag-inbox-oldest-first b/test/tree.expected-output/notmuch-tree-tag-inbox-oldest-first
new file mode 100644
index 0000000..588fc58
--- /dev/null
+++ b/test/tree.expected-output/notmuch-tree-tag-inbox-oldest-first
@@ -0,0 +1,53 @@
+  2009-11-17  Mikhail Gusarov       ┬►[notmuch] [PATCH 1/2] Close message file after parsing message	headers (inbox unread)
+  2009-11-17  Mikhail Gusarov       ├─►[notmuch] [PATCH 2/2] Include <stdint.h> to get uint32_t in C++	file with gcc 4.4 (inbox unread)
+  2009-11-17  Carl Worth            ╰┬►[notmuch] [PATCH 1/2] Close message file after parsing message headers (inbox unread)
+  2009-11-17  Keith Packard          ╰┬► ...                                              (inbox unread)
+  2009-11-18  Carl Worth              ╰─► ...                                             (inbox unread)
+  2009-11-17  Lars Kellogg-Stedman  ┬►[notmuch] Working with Maildir storage?             (inbox signed unread)
+  2009-11-17  Mikhail Gusarov       ├┬► ...                                               (inbox signed unread)
+  2009-11-17  Lars Kellogg-Stedman  │╰┬► ...                                              (inbox signed unread)
+  2009-11-17  Mikhail Gusarov       │ ├─► ...                                             (inbox unread)
+  2009-11-17  Keith Packard         │ ╰┬► ...                                             (inbox unread)
+  2009-11-18  Lars Kellogg-Stedman  │  ╰─► ...                                            (inbox signed unread)
+  2009-11-18  Carl Worth            ╰─► ...                                               (inbox unread)
+  2009-11-17  Alex Botero-Lowry     ┬►[notmuch] preliminary FreeBSD support               (attachment inbox unread)
+  2009-11-17  Carl Worth            ╰─► ...                                               (inbox unread)
+  2009-11-17  Mikhail Gusarov       ─►[notmuch] [PATCH] Handle rename of message file     (inbox unread)
+  2009-11-17  Keith Packard         ┬►[notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove	inbox (and unread) tags (inbox unread)
+  2009-11-18  Carl Worth            ╰─►[notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox unread)
+  2009-11-17  Jan Janak             ┬►[notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
+  2009-11-18  Carl Worth            ╰─► ...                                               (inbox unread)
+  2009-11-17  Jan Janak             ┬►[notmuch] What a great idea!                        (inbox unread)
+  2009-11-17  Jan Janak             ├─► ...                                               (inbox unread)
+  2009-11-18  Carl Worth            ╰─► ...                                               (inbox unread)
+  2009-11-17  Israel Herraiz        ┬►[notmuch] New to the list                           (inbox unread)
+  2009-11-18  Keith Packard         ├─► ...                                               (inbox unread)
+  2009-11-18  Carl Worth            ╰─► ...                                               (inbox unread)
+  2009-11-17  Adrian Perez de Cast  ┬►[notmuch] Introducing myself                        (inbox signed unread)
+  2009-11-18  Keith Packard         ├─► ...                                               (inbox unread)
+  2009-11-18  Carl Worth            ╰─► ...                                               (inbox unread)
+  2009-11-17  Aron Griffis          ┬►[notmuch] archive                                   (inbox unread)
+  2009-11-18  Keith Packard         ╰┬► ...                                               (inbox unread)
+  2009-11-18  Carl Worth             ╰─► ...                                              (inbox unread)
+  2009-11-17  Ingmar Vanhassel      ┬►[notmuch] [PATCH] Typsos                            (inbox unread)
+  2009-11-18  Carl Worth            ╰─► ...                                               (inbox unread)
+  2009-11-18  Alex Botero-Lowry     ┬►[notmuch] [PATCH] Error out if no query is supplied to search	instead of going into an infinite loop (attachment inbox unread)
+  2009-11-18  Carl Worth            ╰─►[notmuch] [PATCH] Error out if no query is supplied to search instead of going into an infinite loop (inbox unread)
+  2009-11-18  Lars Kellogg-Stedman  ┬►[notmuch] "notmuch help" outputs to stderr?         (attachment inbox signed unread)
+  2009-11-18  Lars Kellogg-Stedman  ╰─► ...                                               (attachment inbox signed unread)
+  2009-11-18  Stewart Smith         ─►[notmuch] [PATCH] Fix linking with gcc to use g++ to link in C++	libs. (inbox unread)
+  2009-11-18  Stewart Smith         ─►[notmuch] [PATCH 2/2] Read mail directory in inode number order (inbox unread)
+  2009-11-18  Stewart Smith         ─►[notmuch] [PATCH] count_files: sort directory in inode order before	statting (inbox unread)
+  2009-11-18  Jjgod Jiang           ┬►[notmuch] Mac OS X/Darwin compatibility issues      (inbox unread)
+  2009-11-18  Alexander Botero-Low  ╰┬► ...                                               (inbox unread)
+  2009-11-18  Jjgod Jiang            ╰┬► ...                                              (inbox unread)
+  2009-11-18  Alexander Botero-Low    ╰─► ...                                             (inbox unread)
+  2009-11-18  Jan Janak             ─►[notmuch] [PATCH] notmuch new: Support for conversion of spool	subdirectories into tags (inbox unread)
+  2009-11-18  Rolland Santimano     ─►[notmuch] Link to mailing list archives ?           (inbox unread)
+  2009-11-18  Alexander Botero-Low  ─►[notmuch] request for pull                          (inbox unread)
+  2009-11-18  Keith Packard         ┬►[notmuch] [PATCH] Create a default notmuch-show-hook that	highlights URLs and uses word-wrap (inbox unread)
+  2009-11-18  Alexander Botero-Low  ╰─►[notmuch] [PATCH] Create a default notmuch-show-hook that highlights URLs and uses word-wrap (inbox unread)
+  2009-11-18  Chris Wilson          ─►[notmuch] [PATCH 1/2] Makefile: evaluate pkg-config once (inbox unread)
+  2010-12-16  Olivier Berger        ─►Essai accentué                                      (inbox unread)
+  2010-12-29  François Boulogne     ─►[aur-general] Guidelines: cp, mkdir vs install      (inbox unread)
+End of search results.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] cli: show: allow sort order to be specified
  2015-06-26 22:50 ` [PATCH 1/4] cli: show: allow sort order to be specified Mark Walters
@ 2015-07-31 19:11   ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2015-07-31 19:11 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> This allows the sort to be specified in the notmuch show command with
> a --sort option.
>
> Note that individual threads are still displayed in oldest first
> order, but if the search has multiple threads then these are ordered
> according to this option. This should mean that most callers won't
> notice the option (e.g. the emacs show mode) as they only call show on
> individual threads, but other users, particularly the emacs tree view,
> can use it.
> ---
>  doc/man1/notmuch-show.rst | 17 +++++++++++++++++
>  notmuch-show.c            |  8 ++++++++
>  2 files changed, 25 insertions(+)
>
> diff --git a/doc/man1/notmuch-show.rst b/doc/man1/notmuch-show.rst
> index 9eb5198..7717b08 100644
> --- a/doc/man1/notmuch-show.rst
> +++ b/doc/man1/notmuch-show.rst
> @@ -97,6 +97,23 @@ Supported options for **show** include
>          intended for programs that invoke **notmuch(1)** internally. If
>          omitted, the latest supported version will be used.
>  
> +    ``--sort=``\ (**newest-first**\ \|\ **oldest-first**)
> +        This option can be used to present results in either
> +        chronological order (**oldest-first**) or reverse chronological
> +        order (**newest-first**).
> +
> +        Note: This only affects the order of messages in different
> +        threads: messages inside a thread will always be presented in
> +        thread order.

This phrasing is pretty confusing to me. What about saying something
like

This option can be used to present _threads_ in either ...

Note: this only affects the ordering of threads: messages inside a
thread will always be presented in thread order.

> However, the order of the threads will be distinct
> +        between these two options (beyond being simply reversed). When
> +        sorting by **oldest-first** the threads will be sorted by the
> +        oldest message in each thread, but when sorting by
> +        **newest-first** the threads will be sorted by the newest
> +        message in each thread.
> +
> +        By default, results will be displayed in reverse chronological
> +        order, (that is, the newest results will be displayed first).
> +
>      ``--part=N``
>          Output the single decoded MIME part N of a single message. The
>          search terms must match only a single message. Message parts are
> diff --git a/notmuch-show.c b/notmuch-show.c
> index b80933a..ec9a915 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -1090,6 +1090,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
>      int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
>      int exclude = EXCLUDE_TRUE;
>      int entire_thread = ENTIRE_THREAD_DEFAULT;
> +    notmuch_sort_t sort = NOTMUCH_SORT_NEWEST_FIRST;
>  
>      notmuch_opt_desc_t options[] = {
>  	{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
> @@ -1100,10 +1101,15 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
>  				  { "raw", NOTMUCH_FORMAT_RAW },
>  				  { 0, 0 } } },
>  	{ NOTMUCH_OPT_INT, &notmuch_format_version, "format-version", 0, 0 },
> +	{ NOTMUCH_OPT_KEYWORD, &sort, "sort", 's',
> +	  (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
> +				  { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
> +				  { 0, 0 } } },
>  	{ NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',
>  	  (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
>  				  { "false", EXCLUDE_FALSE },
>  				  { 0, 0 } } },
> +
looks like extra whitespace here
>  	{ NOTMUCH_OPT_KEYWORD, &entire_thread, "entire-thread", 't',
>  	  (notmuch_keyword_t []){ { "true", ENTIRE_THREAD_TRUE },
>  				  { "false", ENTIRE_THREAD_FALSE },
> @@ -1233,6 +1239,8 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
>  	size_t search_exclude_tags_length;
>  	unsigned int i;
>  
> +	notmuch_query_set_sort (query, sort);
> +

hard to argue with that part ;)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] emacs: tree: bind o to toggle sort order
  2015-06-26 22:50 ` [PATCH 2/4] emacs: tree: bind o to toggle sort order Mark Walters
@ 2015-07-31 19:39   ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2015-07-31 19:39 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

If you're redoing the series, it would be good to mention this is the
same binding as notmuch-show mode.

d

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] emacs: tree: add sort argument to notmuch-tree
  2015-06-26 22:50 ` [PATCH 3/4] emacs: tree: add sort argument to notmuch-tree Mark Walters
@ 2015-08-01  5:49   ` David Bremner
  0 siblings, 0 replies; 8+ messages in thread
From: David Bremner @ 2015-08-01  5:49 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> +  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)))

This is probably just me being ignorant, but I had to check the docs for
this usage of interactive. If you think it's tricky also, might be worth
a brief comment.

Otherwise the series looks ok to me.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-08-01  5:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-26 22:50 [PATCH 0/4] Allow oldest-first view in tree view Mark Walters
2015-06-26 22:50 ` [PATCH 1/4] cli: show: allow sort order to be specified Mark Walters
2015-07-31 19:11   ` David Bremner
2015-06-26 22:50 ` [PATCH 2/4] emacs: tree: bind o to toggle sort order Mark Walters
2015-07-31 19:39   ` David Bremner
2015-06-26 22:50 ` [PATCH 3/4] emacs: tree: add sort argument to notmuch-tree Mark Walters
2015-08-01  5:49   ` David Bremner
2015-06-26 22:50 ` [PATCH 4/4] test: tree: fix and a test for tree sort order changes Mark Walters

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).