unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* New --sort for notmuch show and using it in emacs notmuch-tree-mode
@ 2021-06-26  2:28 jao
  2021-06-26  2:28 ` [PATCH 1/7] CLI/show: accept --sort jao
                   ` (8 more replies)
  0 siblings, 9 replies; 24+ messages in thread
From: jao @ 2021-06-26  2:28 UTC (permalink / raw)
  To: notmuch

The accompanying patches implement the new --sort for notmuch show and
its use in emacs to honour :sort-order in saved queries of tree type.

[PATCH 1/7] CLI/show: accept --sort
[PATCH 2/7] emacs/hello: honouring :sort-order in threaded queries
[PATCH 3/7] emacs/tree: command to toggle search sort order in tree
[PATCH 4/7] doc: updates for new --sort and related emacs commands
[PATCH 5/7] CLI/show: tests for the new --sort option
[PATCH 6/7] doc: clarifications for the new --sort flag and emacs
[PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding

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

* [PATCH 1/7] CLI/show: accept --sort
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
@ 2021-06-26  2:28 ` jao
  2021-06-26  2:28 ` [PATCH 2/7] emacs/hello: honouring :sort-order in threaded queries jao
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26  2:28 UTC (permalink / raw)
  To: notmuch; +Cc: jao

Add the command-line option --sort to the show command of the CLI
notmuch interface, with the same possible values as the same option in
notmuch search.
---
 notmuch-show.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/notmuch-show.c b/notmuch-show.c
index bdb87321..947ffa8d 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1244,8 +1244,13 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[])
     bool single_message;
     bool unthreaded = FALSE;
     notmuch_status_t status;
+    int sort = NOTMUCH_SORT_NEWEST_FIRST;
 
     notmuch_opt_desc_t options[] = {
+	{ .opt_keyword = &sort, .name = "sort", .keywords =
+	  (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
+				  { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
+				  { 0, 0 } } },
 	{ .opt_keyword = &format, .name = "format", .keywords =
 	      (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
 				      { "text", NOTMUCH_FORMAT_TEXT },
@@ -1362,6 +1367,8 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[])
 	return EXIT_FAILURE;
     }
 
+    notmuch_query_set_sort (query, sort);
+
     /* Create structure printer. */
     formatter = formatters[format];
     sprinter = formatter->new_sprinter (notmuch, stdout);
-- 
2.32.0

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

* [PATCH 2/7] emacs/hello: honouring :sort-order in threaded queries
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
  2021-06-26  2:28 ` [PATCH 1/7] CLI/show: accept --sort jao
@ 2021-06-26  2:28 ` jao
  2021-06-26  2:28 ` [PATCH 3/7] emacs/tree: command to toggle search sort order in tree mode jao
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26  2:28 UTC (permalink / raw)
  To: notmuch; +Cc: jao

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 00ee78d6..6ef8e439 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1062,7 +1062,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
@@ -1088,6 +1089,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))
@@ -1095,7 +1097,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.
@@ -1114,7 +1116,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:
@@ -1143,7 +1145,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.32.0

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

* [PATCH 3/7] emacs/tree: command to toggle search sort order in tree mode
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
  2021-06-26  2:28 ` [PATCH 1/7] CLI/show: accept --sort jao
  2021-06-26  2:28 ` [PATCH 2/7] emacs/hello: honouring :sort-order in threaded queries jao
@ 2021-06-26  2:28 ` jao
  2021-06-26 10:31   ` David Bremner
  2021-06-26  2:28 ` [PATCH 4/7] doc: updates for new --sort and related emacs commands jao
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 24+ messages in thread
From: jao @ 2021-06-26  2:28 UTC (permalink / raw)
  To: notmuch; +Cc: jao

New command notmuch-tree-toggle-order for switching the sort order (by
reissuing the search with a different flag) in a notmuch-tree buffer.
---
 emacs/notmuch-tree.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 6ef8e439..c23dacfc 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -322,6 +322,7 @@ then NAME behaves like CMD."
     ;; that additionally close the message window.
     (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)
     (define-key map [remap notmuch-search]       'notmuch-tree-to-search)
+    (define-key map [remap notmuch-search]       'notmuch-tree-toggle-order)
     (define-key map [remap notmuch-help]         'notmuch-tree-help)
     (define-key map [remap notmuch-mua-new-mail] 'notmuch-tree-new-mail)
     (define-key map [remap notmuch-jump-search]  'notmuch-tree-jump-search)
@@ -749,7 +750,8 @@ nil otherwise."
 			 query-context
 			 target
 			 nil
-			 unthreaded)))
+			 unthreaded
+			 notmuch-search-oldest-first)))
 
 (defun notmuch-tree-thread-top ()
   (when (notmuch-tree-get-message-properties)
@@ -1071,6 +1073,7 @@ the same as for the function notmuch-tree."
   (interactive)
   (notmuch-tree-mode)
   (add-hook 'post-command-hook #'notmuch-tree-command-hook t t)
+  (setq notmuch-search-oldest-first oldest-first)
   (setq notmuch-tree-unthreaded unthreaded)
   (setq notmuch-tree-basic-query basic-query)
   (setq notmuch-tree-query-context (if (or (string= query-context "")
@@ -1115,6 +1118,15 @@ the same as for the function notmuch-tree."
 	      ")")
     notmuch-tree-basic-query))
 
+(defun notmuch-tree-toggle-order ()
+  "Toggle the current search order.
+
+This command toggles the sort order for the current search. The
+default sort order is defined by `notmuch-search-oldest-first'."
+  (interactive)
+  (setq notmuch-search-oldest-first (not notmuch-search-oldest-first))
+  (notmuch-tree-refresh-view))
+
 (defun notmuch-tree (&optional query query-context target buffer-name
 			       open-target unthreaded parent-buffer oldest-first)
   "Display threads matching QUERY in tree view.
-- 
2.32.0

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

* [PATCH 4/7] doc: updates for new --sort and related emacs commands
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
                   ` (2 preceding siblings ...)
  2021-06-26  2:28 ` [PATCH 3/7] emacs/tree: command to toggle search sort order in tree mode jao
@ 2021-06-26  2:28 ` jao
  2021-06-26 10:36   ` David Bremner
  2021-06-26  2:28 ` [PATCH 5/7] CLI/show: tests for the new --sort option jao
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 24+ messages in thread
From: jao @ 2021-06-26  2:28 UTC (permalink / raw)
  To: notmuch; +Cc: jao

New --sort CLI option documented in notmuch-show's man page, and
notmuch-search-toggle-order mentioned in devel/emacs-keybindings.org.
---
 devel/emacs-keybindings.org | 10 +++++-----
 doc/man1/notmuch-show.rst   |  9 +++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/devel/emacs-keybindings.org b/devel/emacs-keybindings.org
index 65dfe0eb..f7df3040 100644
--- a/devel/emacs-keybindings.org
+++ b/devel/emacs-keybindings.org
@@ -15,7 +15,7 @@
 | l         | notmuch-search-filter                  | notmuch-show-filter-thread                            |                                         |
 | m         | notmuch-mua-new-mail                   | notmuch-mua-new-mail                                  | notmuch-mua-new-mail                    |
 | n         | notmuch-search-next-thread             | notmuch-show-next-open-message                        | notmuch-tree-next-matching-message      |
-| o         | notmuch-search-toggle-order            |                                                       |                                         |
+| o         | notmuch-search-toggle-order            |                                                       | notmuch-tree-toggle-order               |
 | p         | notmuch-search-previous-thread         | notmuch-show-previous-open-message                    | notmuch-tree-prev-matching-message      |
 | q         | notmuch-bury-or-kill-this-buffer       | notmuch-bury-or-kill-this-buffer                      | notmuch-bury-or-kill-this-buffer        |
 | r         | notmuch-search-reply-to-thread-sender  | notmuch-show-reply-sender                             | notmuch-show-reply-sender               |
@@ -38,10 +38,10 @@
 | V         |                                        | notmuch-show-view-raw-message                         | notmuch-show-view-raw-message           |
 | X         |                                        | notmuch-show-archive-thread-then-exit                 |                                         |
 | Z         | notmuch-tree-from-search-current-query | notmuch-tree-from-show-current-query                  |                                         |
-| =!=       |                                        | notmuch-show-toggle-elide-non-matching                |                                         |
-| =#=       |                                        | notmuch-show-print-message                            |                                         |
-| =$=       |                                        | notmuch-show-toggle-process-crypto                    |                                         |
-| =*=       | notmuch-search-tag-all                 | notmuch-show-tag-all                                  | notmuch-tree-tag-thread                 |
+| =!=         |                                        | notmuch-show-toggle-elide-non-matching                |                                         |
+| =#=         |                                        | notmuch-show-print-message                            |                                         |
+| =$=         |                                        | notmuch-show-toggle-process-crypto                    |                                         |
+| =*=         | notmuch-search-tag-all                 | notmuch-show-tag-all                                  | notmuch-tree-tag-thread                 |
 | +         | notmuch-search-add-tag                 | notmuch-show-add-tag                                  | notmuch-tree-add-tag                    |
 | -         | notmuch-search-remove-tag              | notmuch-show-remove-tag                               | notmuch-tree-remove-tag                 |
 | .         |                                        | notmuch-show-part-map                                 |                                         |
diff --git a/doc/man1/notmuch-show.rst b/doc/man1/notmuch-show.rst
index fc6bec62..581d15b5 100644
--- a/doc/man1/notmuch-show.rst
+++ b/doc/man1/notmuch-show.rst
@@ -111,6 +111,15 @@ Supported options for **show** include
    part still has two MIME parts: part 0 is the whole message
    (headers and body) and part 1 is just the body.
 
+.. option:: --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**).
+
+   By default, results will be displayed in reverse chronological
+   order, (that is, the newest results will be displayed first).
+
 .. option:: --verify
 
    Compute and report the validity of any MIME cryptographic
-- 
2.32.0

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

* [PATCH 5/7] CLI/show: tests for the new --sort option
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
                   ` (3 preceding siblings ...)
  2021-06-26  2:28 ` [PATCH 4/7] doc: updates for new --sort and related emacs commands jao
@ 2021-06-26  2:28 ` jao
  2021-06-26  2:28 ` [PATCH 6/7] doc: clarifications for the new --sort flag and emacs command jao
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26  2:28 UTC (permalink / raw)
  To: notmuch; +Cc: jao

New unit tests for notmuch show --sort, covering the basic use cases.
---
 test/T520-show.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/test/T520-show.sh b/test/T520-show.sh
index 16222650..6f42ca12 100755
--- a/test/T520-show.sh
+++ b/test/T520-show.sh
@@ -10,4 +10,21 @@ notmuch show foo..
 exit_code=$?
 test_expect_equal 1 $exit_code
 
+test_begin_subtest "notmuch show --sort=newest-first"
+notmuch show --entire-thread=true '*' > EXPECTED
+notmuch show --entire-thread=true --sort=newest-first '*' > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "notmuch show --sort=oldest-first"
+notmuch show --entire-thread=true '*' | grep ^depth:0 > EXPECTED
+notmuch show --entire-thread=true --sort=oldest-first '*' | grep ^depth:0 > OLDEST
+perl -e 'print reverse<>' OLDEST > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "notmuch show --sort for single thread"
+QUERY="id:yun1vjwegii.fsf@aiko.keithp.com"
+notmuch show --entire-thread=true --sort=newest-first $QUERY > EXPECTED
+notmuch show --entire-thread=true --sort=oldest-first $QUERY > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
-- 
2.32.0

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

* [PATCH 6/7] doc: clarifications for the new --sort flag and emacs command
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
                   ` (4 preceding siblings ...)
  2021-06-26  2:28 ` [PATCH 5/7] CLI/show: tests for the new --sort option jao
@ 2021-06-26  2:28 ` jao
  2021-06-26  2:28 ` [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding jao
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26  2:28 UTC (permalink / raw)
  To: notmuch; +Cc: jao

Improvements to the notmuch show manpage regarding the behaviour of
--sort, and description in doc/notmuch-emacs.rst of the new
notmuch-tree-toggle-order command for notmuch-tree buffers.
---
 doc/man1/notmuch-show.rst | 4 ++++
 doc/notmuch-emacs.rst     | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/doc/man1/notmuch-show.rst b/doc/man1/notmuch-show.rst
index 581d15b5..64639174 100644
--- a/doc/man1/notmuch-show.rst
+++ b/doc/man1/notmuch-show.rst
@@ -117,6 +117,10 @@ Supported options for **show** include
    order (**oldest-first**) or reverse chronological order
    (**newest-first**).
 
+   Only threads as a whole are reordered.  Ordering of messages within
+   each thread will not be affected by this flag, since that order is
+   always determined by the thread's replies.
+
    By default, results will be displayed in reverse chronological
    order, (that is, the newest results will be displayed first).
 
diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
index 7772871b..952fe2a5 100644
--- a/doc/notmuch-emacs.rst
+++ b/doc/notmuch-emacs.rst
@@ -299,12 +299,19 @@ tags.
 ``p``
     Move to previous matching message
 
+``o`` ``notmuch-tree-toggle-order``
+   |docstring::notmuch-tree-toggle-order|
+
 ``g`` ``=``
     Refresh the buffer
 
 ``?``
     Display full set of key bindings
 
+As is the case with :ref:`notmuch-search`, the presentation of results
+can be controlled by the variable ``notmuch-search-oldest-first``.
+
+
 Global key bindings
 ===================
 
-- 
2.32.0

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

* [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
                   ` (5 preceding siblings ...)
  2021-06-26  2:28 ` [PATCH 6/7] doc: clarifications for the new --sort flag and emacs command jao
@ 2021-06-26  2:28 ` jao
  2021-06-26 10:41   ` David Bremner
  2021-06-26 18:02 ` [PATCH 1/5] CLI/show: accept --sort jao
  2021-06-26 18:06 ` Here's a re-roll, with review comments so far addressed jao
  8 siblings, 1 reply; 24+ messages in thread
From: jao @ 2021-06-26  2:28 UTC (permalink / raw)
  To: notmuch; +Cc: jao

Really assign the new emacs command notmuch-tree-toggle-order to o, as
previously documented.
---
 emacs/notmuch-tree.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index c23dacfc..c421cf3f 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -322,11 +322,11 @@ then NAME behaves like CMD."
     ;; that additionally close the message window.
     (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)
     (define-key map [remap notmuch-search]       'notmuch-tree-to-search)
-    (define-key map [remap notmuch-search]       'notmuch-tree-toggle-order)
     (define-key map [remap notmuch-help]         'notmuch-tree-help)
     (define-key map [remap notmuch-mua-new-mail] 'notmuch-tree-new-mail)
     (define-key map [remap notmuch-jump-search]  'notmuch-tree-jump-search)
 
+    (define-key map "o" 'notmuch-tree-toggle-order)
     (define-key map "S" 'notmuch-search-from-tree-current-query)
     (define-key map "U" 'notmuch-unthreaded-from-tree-current-query)
     (define-key map "Z" 'notmuch-tree-from-unthreaded-current-query)
-- 
2.32.0

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

* Re: [PATCH 3/7] emacs/tree: command to toggle search sort order in tree mode
  2021-06-26  2:28 ` [PATCH 3/7] emacs/tree: command to toggle search sort order in tree mode jao
@ 2021-06-26 10:31   ` David Bremner
  2021-06-26 15:38     ` Jose Antonio Ortega Ruiz
  0 siblings, 1 reply; 24+ messages in thread
From: David Bremner @ 2021-06-26 10:31 UTC (permalink / raw)
  To: jao, notmuch; +Cc: jao

jao <jao@gnu.org> writes:

> New command notmuch-tree-toggle-order for switching the sort order (by
> reissuing the search with a different flag) in a notmuch-tree buffer.
> ---
>  emacs/notmuch-tree.el | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index 6ef8e439..c23dacfc 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -322,6 +322,7 @@ then NAME behaves like CMD."
>      ;; that additionally close the message window.
>      (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)
>      (define-key map [remap notmuch-search]       'notmuch-tree-to-search)
> +    (define-key map [remap notmuch-search]       'notmuch-tree-toggle-order)
>      (define-key map [remap notmuch-help]         'notmuch-tree-help)
>      (define-key map [remap notmuch-mua-new-mail] 'notmuch-tree-new-mail)
>      (define-key map [remap notmuch-jump-search]  'notmuch-tree-jump-search)

That remap command looks like a copy-paste failure. Does it actually
work?

d

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

* Re: [PATCH 4/7] doc: updates for new --sort and related emacs commands
  2021-06-26  2:28 ` [PATCH 4/7] doc: updates for new --sort and related emacs commands jao
@ 2021-06-26 10:36   ` David Bremner
  0 siblings, 0 replies; 24+ messages in thread
From: David Bremner @ 2021-06-26 10:36 UTC (permalink / raw)
  To: jao, notmuch; +Cc: jao

jao <jao@gnu.org> writes:

                   |
> -| =!=       |                                        | notmuch-show-toggle-elide-non-matching                |                                         |
> -| =#=       |                                        | notmuch-show-print-message                            |                                         |
> -| =$=       |                                        | notmuch-show-toggle-process-crypto                    |                                         |
> -| =*=       | notmuch-search-tag-all                 | notmuch-show-tag-all                                  | notmuch-tree-tag-thread                 |
> +| =!=         |                                        | notmuch-show-toggle-elide-non-matching                |                                         |
> +| =#=         |                                        | notmuch-show-print-message                            |                                         |
> +| =$=         |                                        | notmuch-show-toggle-process-crypto                    |                                         |
> +| =*=         | notmuch-search-tag-all                 | notmuch-show-tag-all                                  | notmuch-tree-tag-thread                 |
>  | +         | notmuch-search-add-tag                 | notmuch-show-add-tag                                  | notmuch-tree-add-tag                    |
>  | -         | notmuch-search-remove-tag              | notmuch-show-remove-tag                               | notmuch-tree-remove-tag                 |
>  | .         |                                        |
>  notmuch-show-part-map                                 |

If you are regenerating the series, consider mentioning the whitespace
change here is org-mode's fault. It took me a minute to come to that conclusion.

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

* Re: [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding
  2021-06-26  2:28 ` [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding jao
@ 2021-06-26 10:41   ` David Bremner
  2021-06-26 10:46     ` David Bremner
  0 siblings, 1 reply; 24+ messages in thread
From: David Bremner @ 2021-06-26 10:41 UTC (permalink / raw)
  To: jao, notmuch; +Cc: jao

jao <jao@gnu.org> writes:

> Really assign the new emacs command notmuch-tree-toggle-order to o, as
> previously documented.

It seems like this one should be merged with 3/7?

d

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

* Re: [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding
  2021-06-26 10:41   ` David Bremner
@ 2021-06-26 10:46     ` David Bremner
  2021-06-26 15:41       ` Jose Antonio Ortega Ruiz
  0 siblings, 1 reply; 24+ messages in thread
From: David Bremner @ 2021-06-26 10:46 UTC (permalink / raw)
  To: jao, notmuch; +Cc: jao

David Bremner <david@tethera.net> writes:

> jao <jao@gnu.org> writes:
>
>> Really assign the new emacs command notmuch-tree-toggle-order to o, as
>> previously documented.
>
> It seems like this one should be merged with 3/7?
>
> d

Apologies for the many replies, but can't you remap notmuch-search-toggle-order?

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

* Re: [PATCH 3/7] emacs/tree: command to toggle search sort order in tree mode
  2021-06-26 10:31   ` David Bremner
@ 2021-06-26 15:38     ` Jose Antonio Ortega Ruiz
  0 siblings, 0 replies; 24+ messages in thread
From: Jose Antonio Ortega Ruiz @ 2021-06-26 15:38 UTC (permalink / raw)
  To: notmuch

On Sat, Jun 26 2021, David Bremner wrote:

> jao <jao@gnu.org> writes:
>
>> New command notmuch-tree-toggle-order for switching the sort order (by
>> reissuing the search with a different flag) in a notmuch-tree buffer.
>> ---
>>  emacs/notmuch-tree.el | 14 +++++++++++++-
>>  1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
>> index 6ef8e439..c23dacfc 100644
>> --- a/emacs/notmuch-tree.el
>> +++ b/emacs/notmuch-tree.el
>> @@ -322,6 +322,7 @@ then NAME behaves like CMD."
>>      ;; that additionally close the message window.
>>      (define-key map [remap notmuch-bury-or-kill-this-buffer] 'notmuch-tree-quit)
>>      (define-key map [remap notmuch-search]       'notmuch-tree-to-search)
>> +    (define-key map [remap notmuch-search]       'notmuch-tree-toggle-order)
>>      (define-key map [remap notmuch-help]         'notmuch-tree-help)
>>      (define-key map [remap notmuch-mua-new-mail] 'notmuch-tree-new-mail)
>>      (define-key map [remap notmuch-jump-search]  'notmuch-tree-jump-search)
>
> That remap command looks like a copy-paste failure. Does it actually
> work?

it was a copy-paste failure, yes. it's fixed in patch 7.

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

* Re: [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding
  2021-06-26 10:46     ` David Bremner
@ 2021-06-26 15:41       ` Jose Antonio Ortega Ruiz
  2021-06-26 16:55         ` Jose Antonio Ortega Ruiz
  0 siblings, 1 reply; 24+ messages in thread
From: Jose Antonio Ortega Ruiz @ 2021-06-26 15:41 UTC (permalink / raw)
  To: David Bremner, notmuch

On Sat, Jun 26 2021, David Bremner wrote:

> David Bremner <david@tethera.net> writes:
>
>> jao <jao@gnu.org> writes:
>>
>>> Really assign the new emacs command notmuch-tree-toggle-order to o, as
>>> previously documented.
>>
>> It seems like this one should be merged with 3/7?
>>
>> d
>
> Apologies for the many replies, but can't you remap notmuch-search-toggle-order?

i tried, but it wasn't working for some reason i have forgotten.  i'll
try again, re-base, and submit a new batch.  thanks for reviewing.

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

* Re: [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding
  2021-06-26 15:41       ` Jose Antonio Ortega Ruiz
@ 2021-06-26 16:55         ` Jose Antonio Ortega Ruiz
  2021-06-26 17:42           ` David Bremner
  0 siblings, 1 reply; 24+ messages in thread
From: Jose Antonio Ortega Ruiz @ 2021-06-26 16:55 UTC (permalink / raw)
  To: David Bremner, notmuch

On Sat, Jun 26 2021, Jose Antonio Ortega Ruiz wrote:

> On Sat, Jun 26 2021, David Bremner wrote:
>
>> David Bremner <david@tethera.net> writes:
>>
>>> jao <jao@gnu.org> writes:
>>>
>>>> Really assign the new emacs command notmuch-tree-toggle-order to o, as
>>>> previously documented.
>>>
>>> It seems like this one should be merged with 3/7?
>>>
>>> d
>>
>> Apologies for the many replies, but can't you remap notmuch-search-toggle-order?
>
> i tried, but it wasn't working for some reason i have forgotten.  i'll
> try again, re-base, and submit a new batch.  thanks for reviewing.

Ah, i just remembered the reason: notmuch-search-toggle-order is not
bound in notmuch-common-keymap, so, no, i think that it cannot be
remapped here.

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

* Re: [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding
  2021-06-26 16:55         ` Jose Antonio Ortega Ruiz
@ 2021-06-26 17:42           ` David Bremner
  2021-06-26 18:08             ` Jose Antonio Ortega Ruiz
  0 siblings, 1 reply; 24+ messages in thread
From: David Bremner @ 2021-06-26 17:42 UTC (permalink / raw)
  To: Jose Antonio Ortega Ruiz, notmuch

Jose Antonio Ortega Ruiz <jao@gnu.org> writes:

> Ah, i just remembered the reason: notmuch-search-toggle-order is not
> bound in notmuch-common-keymap, so, no, i think that it cannot be
> remapped here.

OIC. OK, so just definine it correctly the first time?

d

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

* [PATCH 1/5] CLI/show: accept --sort
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
                   ` (6 preceding siblings ...)
  2021-06-26  2:28 ` [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding jao
@ 2021-06-26 18:02 ` jao
  2021-06-26 18:06 ` Here's a re-roll, with review comments so far addressed jao
  8 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26 18:02 UTC (permalink / raw)
  To: notmuch; +Cc: jao

Add the command-line option --sort to the show command of the CLI
notmuch interface, with the same possible values as the same option in
notmuch search.
---
 notmuch-show.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/notmuch-show.c b/notmuch-show.c
index bdb87321..947ffa8d 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1244,8 +1244,13 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[])
     bool single_message;
     bool unthreaded = FALSE;
     notmuch_status_t status;
+    int sort = NOTMUCH_SORT_NEWEST_FIRST;
 
     notmuch_opt_desc_t options[] = {
+	{ .opt_keyword = &sort, .name = "sort", .keywords =
+	  (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
+				  { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
+				  { 0, 0 } } },
 	{ .opt_keyword = &format, .name = "format", .keywords =
 	      (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
 				      { "text", NOTMUCH_FORMAT_TEXT },
@@ -1362,6 +1367,8 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[])
 	return EXIT_FAILURE;
     }
 
+    notmuch_query_set_sort (query, sort);
+
     /* Create structure printer. */
     formatter = formatters[format];
     sprinter = formatter->new_sprinter (notmuch, stdout);
-- 
2.32.0

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

* Here's a re-roll, with review comments so far addressed
  2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
                   ` (7 preceding siblings ...)
  2021-06-26 18:02 ` [PATCH 1/5] CLI/show: accept --sort jao
@ 2021-06-26 18:06 ` jao
  2021-06-26 18:06   ` [PATCH 1/5] CLI/show: accept --sort jao
                     ` (4 more replies)
  8 siblings, 5 replies; 24+ messages in thread
From: jao @ 2021-06-26 18:06 UTC (permalink / raw)
  To: notmuch

[PATCH 1/5] CLI/show: accept --sort
[PATCH 2/5] CLI/show: tests for the new --sort option
[PATCH 3/5] emacs/hello: honouring :sort-order in threaded queries
[PATCH 4/5] emacs/tree: command to toggle search sort order in tree
[PATCH 5/5] doc: new notmuch show --sort and related emacs commands

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

* [PATCH 1/5] CLI/show: accept --sort
  2021-06-26 18:06 ` Here's a re-roll, with review comments so far addressed jao
@ 2021-06-26 18:06   ` jao
  2021-06-26 18:06   ` [PATCH 2/5] CLI/show: tests for the new --sort option jao
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26 18:06 UTC (permalink / raw)
  To: notmuch; +Cc: jao

Add the command-line option --sort to the show command of the CLI
notmuch interface, with the same possible values as the same option in
notmuch search.
---
 notmuch-show.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/notmuch-show.c b/notmuch-show.c
index bdb87321..947ffa8d 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1244,8 +1244,13 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[])
     bool single_message;
     bool unthreaded = FALSE;
     notmuch_status_t status;
+    int sort = NOTMUCH_SORT_NEWEST_FIRST;
 
     notmuch_opt_desc_t options[] = {
+	{ .opt_keyword = &sort, .name = "sort", .keywords =
+	  (notmuch_keyword_t []){ { "oldest-first", NOTMUCH_SORT_OLDEST_FIRST },
+				  { "newest-first", NOTMUCH_SORT_NEWEST_FIRST },
+				  { 0, 0 } } },
 	{ .opt_keyword = &format, .name = "format", .keywords =
 	      (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
 				      { "text", NOTMUCH_FORMAT_TEXT },
@@ -1362,6 +1367,8 @@ notmuch_show_command (notmuch_database_t *notmuch, int argc, char *argv[])
 	return EXIT_FAILURE;
     }
 
+    notmuch_query_set_sort (query, sort);
+
     /* Create structure printer. */
     formatter = formatters[format];
     sprinter = formatter->new_sprinter (notmuch, stdout);
-- 
2.32.0

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

* [PATCH 2/5] CLI/show: tests for the new --sort option
  2021-06-26 18:06 ` Here's a re-roll, with review comments so far addressed jao
  2021-06-26 18:06   ` [PATCH 1/5] CLI/show: accept --sort jao
@ 2021-06-26 18:06   ` jao
  2021-06-26 18:06   ` [PATCH 3/5] emacs/hello: honouring :sort-order in threaded queries jao
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26 18:06 UTC (permalink / raw)
  To: notmuch; +Cc: jao

New unit tests for notmuch show --sort, covering the basic use cases.
---
 test/T520-show.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/test/T520-show.sh b/test/T520-show.sh
index 16222650..6f42ca12 100755
--- a/test/T520-show.sh
+++ b/test/T520-show.sh
@@ -10,4 +10,21 @@ notmuch show foo..
 exit_code=$?
 test_expect_equal 1 $exit_code
 
+test_begin_subtest "notmuch show --sort=newest-first"
+notmuch show --entire-thread=true '*' > EXPECTED
+notmuch show --entire-thread=true --sort=newest-first '*' > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "notmuch show --sort=oldest-first"
+notmuch show --entire-thread=true '*' | grep ^depth:0 > EXPECTED
+notmuch show --entire-thread=true --sort=oldest-first '*' | grep ^depth:0 > OLDEST
+perl -e 'print reverse<>' OLDEST > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
+test_begin_subtest "notmuch show --sort for single thread"
+QUERY="id:yun1vjwegii.fsf@aiko.keithp.com"
+notmuch show --entire-thread=true --sort=newest-first $QUERY > EXPECTED
+notmuch show --entire-thread=true --sort=oldest-first $QUERY > OUTPUT
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done
-- 
2.32.0

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

* [PATCH 3/5] emacs/hello: honouring :sort-order in threaded queries
  2021-06-26 18:06 ` Here's a re-roll, with review comments so far addressed jao
  2021-06-26 18:06   ` [PATCH 1/5] CLI/show: accept --sort jao
  2021-06-26 18:06   ` [PATCH 2/5] CLI/show: tests for the new --sort option jao
@ 2021-06-26 18:06   ` jao
  2021-06-26 18:06   ` [PATCH 4/5] emacs/tree: command to toggle search sort order in tree mode jao
  2021-06-26 18:06   ` [PATCH 5/5] doc: new notmuch show --sort and related emacs commands jao
  4 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26 18:06 UTC (permalink / raw)
  To: notmuch; +Cc: jao

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 00ee78d6..6ef8e439 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -1062,7 +1062,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
@@ -1088,6 +1089,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))
@@ -1095,7 +1097,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.
@@ -1114,7 +1116,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:
@@ -1143,7 +1145,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.32.0

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

* [PATCH 4/5] emacs/tree: command to toggle search sort order in tree mode
  2021-06-26 18:06 ` Here's a re-roll, with review comments so far addressed jao
                     ` (2 preceding siblings ...)
  2021-06-26 18:06   ` [PATCH 3/5] emacs/hello: honouring :sort-order in threaded queries jao
@ 2021-06-26 18:06   ` jao
  2021-06-26 18:06   ` [PATCH 5/5] doc: new notmuch show --sort and related emacs commands jao
  4 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26 18:06 UTC (permalink / raw)
  To: notmuch; +Cc: jao

New command notmuch-tree-toggle-order for switching the sort order (by
reissuing the search with a different flag) in a notmuch-tree buffer.
---
 emacs/notmuch-tree.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 6ef8e439..c421cf3f 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -326,6 +326,7 @@ then NAME behaves like CMD."
     (define-key map [remap notmuch-mua-new-mail] 'notmuch-tree-new-mail)
     (define-key map [remap notmuch-jump-search]  'notmuch-tree-jump-search)
 
+    (define-key map "o" 'notmuch-tree-toggle-order)
     (define-key map "S" 'notmuch-search-from-tree-current-query)
     (define-key map "U" 'notmuch-unthreaded-from-tree-current-query)
     (define-key map "Z" 'notmuch-tree-from-unthreaded-current-query)
@@ -749,7 +750,8 @@ nil otherwise."
 			 query-context
 			 target
 			 nil
-			 unthreaded)))
+			 unthreaded
+			 notmuch-search-oldest-first)))
 
 (defun notmuch-tree-thread-top ()
   (when (notmuch-tree-get-message-properties)
@@ -1071,6 +1073,7 @@ the same as for the function notmuch-tree."
   (interactive)
   (notmuch-tree-mode)
   (add-hook 'post-command-hook #'notmuch-tree-command-hook t t)
+  (setq notmuch-search-oldest-first oldest-first)
   (setq notmuch-tree-unthreaded unthreaded)
   (setq notmuch-tree-basic-query basic-query)
   (setq notmuch-tree-query-context (if (or (string= query-context "")
@@ -1115,6 +1118,15 @@ the same as for the function notmuch-tree."
 	      ")")
     notmuch-tree-basic-query))
 
+(defun notmuch-tree-toggle-order ()
+  "Toggle the current search order.
+
+This command toggles the sort order for the current search. The
+default sort order is defined by `notmuch-search-oldest-first'."
+  (interactive)
+  (setq notmuch-search-oldest-first (not notmuch-search-oldest-first))
+  (notmuch-tree-refresh-view))
+
 (defun notmuch-tree (&optional query query-context target buffer-name
 			       open-target unthreaded parent-buffer oldest-first)
   "Display threads matching QUERY in tree view.
-- 
2.32.0

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

* [PATCH 5/5] doc: new notmuch show --sort and related emacs commands
  2021-06-26 18:06 ` Here's a re-roll, with review comments so far addressed jao
                     ` (3 preceding siblings ...)
  2021-06-26 18:06   ` [PATCH 4/5] emacs/tree: command to toggle search sort order in tree mode jao
@ 2021-06-26 18:06   ` jao
  4 siblings, 0 replies; 24+ messages in thread
From: jao @ 2021-06-26 18:06 UTC (permalink / raw)
  To: notmuch; +Cc: jao

New --sort CLI option documented in notmuch-show's man page, and
notmuch-search-toggle-order mentioned in doc/notmuch-emacs.rst and
devel/emacs-keybindings.org (in the latter, there's also some
whitespace changes in a table introduced by org-mode).
---
 devel/emacs-keybindings.org | 10 +++++-----
 doc/man1/notmuch-show.rst   | 13 +++++++++++++
 doc/notmuch-emacs.rst       |  7 +++++++
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/devel/emacs-keybindings.org b/devel/emacs-keybindings.org
index 65dfe0eb..f7df3040 100644
--- a/devel/emacs-keybindings.org
+++ b/devel/emacs-keybindings.org
@@ -15,7 +15,7 @@
 | l         | notmuch-search-filter                  | notmuch-show-filter-thread                            |                                         |
 | m         | notmuch-mua-new-mail                   | notmuch-mua-new-mail                                  | notmuch-mua-new-mail                    |
 | n         | notmuch-search-next-thread             | notmuch-show-next-open-message                        | notmuch-tree-next-matching-message      |
-| o         | notmuch-search-toggle-order            |                                                       |                                         |
+| o         | notmuch-search-toggle-order            |                                                       | notmuch-tree-toggle-order               |
 | p         | notmuch-search-previous-thread         | notmuch-show-previous-open-message                    | notmuch-tree-prev-matching-message      |
 | q         | notmuch-bury-or-kill-this-buffer       | notmuch-bury-or-kill-this-buffer                      | notmuch-bury-or-kill-this-buffer        |
 | r         | notmuch-search-reply-to-thread-sender  | notmuch-show-reply-sender                             | notmuch-show-reply-sender               |
@@ -38,10 +38,10 @@
 | V         |                                        | notmuch-show-view-raw-message                         | notmuch-show-view-raw-message           |
 | X         |                                        | notmuch-show-archive-thread-then-exit                 |                                         |
 | Z         | notmuch-tree-from-search-current-query | notmuch-tree-from-show-current-query                  |                                         |
-| =!=       |                                        | notmuch-show-toggle-elide-non-matching                |                                         |
-| =#=       |                                        | notmuch-show-print-message                            |                                         |
-| =$=       |                                        | notmuch-show-toggle-process-crypto                    |                                         |
-| =*=       | notmuch-search-tag-all                 | notmuch-show-tag-all                                  | notmuch-tree-tag-thread                 |
+| =!=         |                                        | notmuch-show-toggle-elide-non-matching                |                                         |
+| =#=         |                                        | notmuch-show-print-message                            |                                         |
+| =$=         |                                        | notmuch-show-toggle-process-crypto                    |                                         |
+| =*=         | notmuch-search-tag-all                 | notmuch-show-tag-all                                  | notmuch-tree-tag-thread                 |
 | +         | notmuch-search-add-tag                 | notmuch-show-add-tag                                  | notmuch-tree-add-tag                    |
 | -         | notmuch-search-remove-tag              | notmuch-show-remove-tag                               | notmuch-tree-remove-tag                 |
 | .         |                                        | notmuch-show-part-map                                 |                                         |
diff --git a/doc/man1/notmuch-show.rst b/doc/man1/notmuch-show.rst
index fc6bec62..64639174 100644
--- a/doc/man1/notmuch-show.rst
+++ b/doc/man1/notmuch-show.rst
@@ -111,6 +111,19 @@ Supported options for **show** include
    part still has two MIME parts: part 0 is the whole message
    (headers and body) and part 1 is just the body.
 
+.. option:: --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**).
+
+   Only threads as a whole are reordered.  Ordering of messages within
+   each thread will not be affected by this flag, since that order is
+   always determined by the thread's replies.
+
+   By default, results will be displayed in reverse chronological
+   order, (that is, the newest results will be displayed first).
+
 .. option:: --verify
 
    Compute and report the validity of any MIME cryptographic
diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst
index 7772871b..952fe2a5 100644
--- a/doc/notmuch-emacs.rst
+++ b/doc/notmuch-emacs.rst
@@ -299,12 +299,19 @@ tags.
 ``p``
     Move to previous matching message
 
+``o`` ``notmuch-tree-toggle-order``
+   |docstring::notmuch-tree-toggle-order|
+
 ``g`` ``=``
     Refresh the buffer
 
 ``?``
     Display full set of key bindings
 
+As is the case with :ref:`notmuch-search`, the presentation of results
+can be controlled by the variable ``notmuch-search-oldest-first``.
+
+
 Global key bindings
 ===================
 
-- 
2.32.0

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

* Re: [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding
  2021-06-26 17:42           ` David Bremner
@ 2021-06-26 18:08             ` Jose Antonio Ortega Ruiz
  0 siblings, 0 replies; 24+ messages in thread
From: Jose Antonio Ortega Ruiz @ 2021-06-26 18:08 UTC (permalink / raw)
  To: David Bremner, notmuch

On Sat, Jun 26 2021, David Bremner wrote:

> Jose Antonio Ortega Ruiz <jao@gnu.org> writes:
>
>> Ah, i just remembered the reason: notmuch-search-toggle-order is not
>> bound in notmuch-common-keymap, so, no, i think that it cannot be
>> remapped here.
>
> OIC. OK, so just definine it correctly the first time?

yeah... i just submitted a new set with that and your other comments
hopefully addressed: let me know otherwise! thanks.

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

end of thread, other threads:[~2021-06-26 18:08 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-26  2:28 New --sort for notmuch show and using it in emacs notmuch-tree-mode jao
2021-06-26  2:28 ` [PATCH 1/7] CLI/show: accept --sort jao
2021-06-26  2:28 ` [PATCH 2/7] emacs/hello: honouring :sort-order in threaded queries jao
2021-06-26  2:28 ` [PATCH 3/7] emacs/tree: command to toggle search sort order in tree mode jao
2021-06-26 10:31   ` David Bremner
2021-06-26 15:38     ` Jose Antonio Ortega Ruiz
2021-06-26  2:28 ` [PATCH 4/7] doc: updates for new --sort and related emacs commands jao
2021-06-26 10:36   ` David Bremner
2021-06-26  2:28 ` [PATCH 5/7] CLI/show: tests for the new --sort option jao
2021-06-26  2:28 ` [PATCH 6/7] doc: clarifications for the new --sort flag and emacs command jao
2021-06-26  2:28 ` [PATCH 7/7] emacs: fix notmuch-tree-toggle-order keybinding jao
2021-06-26 10:41   ` David Bremner
2021-06-26 10:46     ` David Bremner
2021-06-26 15:41       ` Jose Antonio Ortega Ruiz
2021-06-26 16:55         ` Jose Antonio Ortega Ruiz
2021-06-26 17:42           ` David Bremner
2021-06-26 18:08             ` Jose Antonio Ortega Ruiz
2021-06-26 18:02 ` [PATCH 1/5] CLI/show: accept --sort jao
2021-06-26 18:06 ` Here's a re-roll, with review comments so far addressed jao
2021-06-26 18:06   ` [PATCH 1/5] CLI/show: accept --sort jao
2021-06-26 18:06   ` [PATCH 2/5] CLI/show: tests for the new --sort option jao
2021-06-26 18:06   ` [PATCH 3/5] emacs/hello: honouring :sort-order in threaded queries jao
2021-06-26 18:06   ` [PATCH 4/5] emacs/tree: command to toggle search sort order in tree mode jao
2021-06-26 18:06   ` [PATCH 5/5] doc: new notmuch show --sort and related emacs commands jao

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