From 906d0684436d3506c30e1def3b40753111b7e9a2 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Fri, 26 Jun 2015 23:50:32 +0100 Subject: [PATCH] [PATCH 1/4] cli: show: allow sort order to be specified --- 32/3d5b07cf1d684fa0888ccef769f8df1c323bd6 | 144 ++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 32/3d5b07cf1d684fa0888ccef769f8df1c323bd6 diff --git a/32/3d5b07cf1d684fa0888ccef769f8df1c323bd6 b/32/3d5b07cf1d684fa0888ccef769f8df1c323bd6 new file mode 100644 index 000000000..b1f278eb4 --- /dev/null +++ b/32/3d5b07cf1d684fa0888ccef769f8df1c323bd6 @@ -0,0 +1,144 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 84A446DE0274 + for ; Fri, 26 Jun 2015 15:50:52 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.183 +X-Spam-Level: +X-Spam-Status: No, score=0.183 tagged_above=-999 required=5 tests=[AWL=0.753, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 9LJjDHS6SHIE for ; + Fri, 26 Jun 2015 15:50:51 -0700 (PDT) +Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com + [209.85.212.169]) + by arlo.cworth.org (Postfix) with ESMTPS id 8CF306DE1390 + for ; Fri, 26 Jun 2015 15:50:50 -0700 (PDT) +Received: by wicnd19 with SMTP id nd19so28679530wic.1 + for ; Fri, 26 Jun 2015 15:50:47 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=/0dh4q60v0Remj4lrIjV2Qy8GDgZv5qjHjVzsIV+VsM=; + b=UQLjNdnSI27KBD6ICZJNjO7vgZ0RA/xXmGdlSJv+yrkW8tTTE/yOzMowSwfgOO5hMm + pfpN5CbZA4du3lSCyPq0szTxvgMpt/MuNObZ8hoCNj4VA+wWd4vOtlxrID997jHR7pKY + OkuydTBs6qPMHiMRBdsicH39W878X1LplqM614WSFmTUyiD06A687dX9LEBsaIrXbw+z + oxhhvX6v80YKRt5yTUJQjf+iJAwuWXDLezYvG1b1Qlb2WUKD/wciJD/GVPqdPshJjOeq + qulbdOWkRXRHFMH+P/WcbuJ195950SUgGmbWW+YD/sgE7uj4dmeqBq4z8E8vE7dW+iPD + l/Ig== +X-Received: by 10.181.11.129 with SMTP id ei1mr711298wid.90.1435359047828; + Fri, 26 Jun 2015 15:50:47 -0700 (PDT) +Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) + by mx.google.com with ESMTPSA id ck18sm43758964wjb.47.2015.06.26.15.50.46 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Fri, 26 Jun 2015 15:50:47 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 1/4] cli: show: allow sort order to be specified +Date: Fri, 26 Jun 2015 23:50:32 +0100 +Message-Id: <1435359035-6767-2-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1435359035-6767-1-git-send-email-markwalters1009@gmail.com> +References: <1435359035-6767-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 26 Jun 2015 22:50:52 -0000 + +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, ¬much_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 + -- 2.26.2