Add the option --sort=newest-first|oldest-first to notmuch-show. This
is used by notmuch-pick.el
---
 notmuch-show.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 9d73685..8f6e520 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1030,6 +1030,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
     notmuch_query_t *query;
     char *query_string;
     int opt_index, ret;
+    notmuch_sort_t sort = NOTMUCH_SORT_NEWEST_FIRST;
     const notmuch_show_format_t *format = &format_text;
     notmuch_show_params_t params = { .part = -1 };
     int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
@@ -1043,6 +1044,10 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
                                  { "mbox", NOTMUCH_FORMAT_MBOX },
                                  { "raw", NOTMUCH_FORMAT_RAW },
                                  { 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_INT, &params.part, "part", 'p', 0 },
        { NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },
        { NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },
@@ -1137,6 +1142,8 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
        return 1;
     }

+    notmuch_query_set_sort (query, sort);
+
     if (params.part >= 0)
        ret = do_show_single (ctx, query, format, &params);
     else
-- 
1.7.2.3

Reply via email to