From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 6A4CA6DE0F4F for ; Thu, 27 Feb 2020 09:17:03 -0800 (PST) Authentication-Results: arlo.cworth.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pbizpL/9"; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.041 X-Spam-Level: X-Spam-Status: No, score=0.041 tagged_above=-999 required=5 tests=[AWL=-0.008, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 696E3K_40bOY for ; Thu, 27 Feb 2020 09:17:02 -0800 (PST) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by arlo.cworth.org (Postfix) with ESMTPS id B5E296DE0F90 for ; Thu, 27 Feb 2020 09:17:02 -0800 (PST) Received: by mail-wr1-f65.google.com with SMTP id y17so4393843wrn.6 for ; Thu, 27 Feb 2020 09:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+nVRUQWyOgtMEC7DyIaNAy4gx+JvwkTsdOIAp4ckTb8=; b=pbizpL/9lyO8CLLTVOY4EXc2aj7bo9UxfAsctRgUpi26TqpUhS49e0vXDWqOxt071M qwRwpRXcZB4pRqluB4Lu4U8InNkqTG2a9ed3HSbQRoaagSmhdj9YlXdREY8HfMLKXle7 kGVA9iXZclroaP/l57cZQ7XltSN+9fz5GVPqXtZWIXTtO8zYQjxngAuCSyK8arsUdgXX APaK7qRUr4it4UaeFhpOBsvsl37SvttovRQgs7g4pojSI1KddQJLRavo1ShYl5bBOh4h kYWav+Hb89anCXd1Dh8j+hB6fPlm1NQUXQ34xts8RsQ8AOE3nxhIVdRuuTp5ldP7xqDc xRpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+nVRUQWyOgtMEC7DyIaNAy4gx+JvwkTsdOIAp4ckTb8=; b=nMMuM5YB2daUi3vqAmY8H/KKr3aSu0PECFJr6PHWYOhL9AFBlh0xzPp1ZzZpOtnHUs 20OCzNAdXFNecQSuqvJj/XW6crNSlojJP0nThSIYk9hhXueGD9XcQHLTItqK6F/QKrDi CwRM++CXwYYOc3qUI0vUiTIUYR0yK7EE8WXrhd2xcw9qkuGd/1ypAWpPlIWGs5ExBCIh gddy8fRafQi9jXfoBx2vMQSttujYEPm8ubijCUQVqmGuMWawQWQ49cs7CknS3dbdmEXJ SUC6sb96yS3TicgLLm2xgi+Xx8GZTy1f11LgU1D4Mv0PrBdcUei1D1DcCVKb9q8IU7xh bRKA== X-Gm-Message-State: APjAAAU863Qmr6eG3WeK+z7P9sbegSJAebIQ+iyECvNNO23ZpkEZ9sMA HOeQ2PgR3oHJ51JejR+h69uUhaYZ X-Google-Smtp-Source: APXvYqx58jWHe58plgkm7QlK810TYYVvzrP8CikHduoJd+IYCbaVk+e4ST63A5QE+LsXxv0TZ3aqiQ== X-Received: by 2002:adf:f892:: with SMTP id u18mr5571460wrp.328.1582823821096; Thu, 27 Feb 2020 09:17:01 -0800 (PST) Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162]) by smtp.gmail.com with ESMTPSA id h15sm1734759wrr.73.2020.02.27.09.17.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Feb 2020 09:17:00 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH 1/6] notmuch-show.c: add an option for messages to be returned unthreaded Date: Thu, 27 Feb 2020 17:16:47 +0000 Message-Id: <20200227171652.18187-2-markwalters1009@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200227171652.18187-1-markwalters1009@gmail.com> References: <20200227171652.18187-1-markwalters1009@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 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: Thu, 27 Feb 2020 17:17:03 -0000 This adds a --unthreaded option to notmuch show to tell it to return the matching messages in an unthreaded order (so just by date). To make it easier for users, in particular for notmuch-tree.el, we output each message with the same "nesting" as if it were an entire thread in its own right. --- notmuch-show.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 21792a57..cf543ed9 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1066,11 +1066,11 @@ do_show_single (void *ctx, /* Formatted output of threads */ static int -do_show (void *ctx, - notmuch_query_t *query, - const notmuch_show_format_t *format, - sprinter_t *sp, - notmuch_show_params_t *params) +do_show_threaded (void *ctx, + notmuch_query_t *query, + const notmuch_show_format_t *format, + sprinter_t *sp, + notmuch_show_params_t *params) { notmuch_threads_t *threads; notmuch_thread_t *thread; @@ -1107,6 +1107,50 @@ do_show (void *ctx, return res != NOTMUCH_STATUS_SUCCESS; } +static int +do_show_unthreaded (void *ctx, + notmuch_query_t *query, + const notmuch_show_format_t *format, + sprinter_t *sp, + notmuch_show_params_t *params) +{ + notmuch_messages_t *messages; + notmuch_message_t *message; + notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; + notmuch_bool_t excluded; + + status= notmuch_query_search_messages (query, &messages); + if (print_status_query ("notmuch show", query, status)) + return 1; + + sp->begin_list (sp); + + for (; + notmuch_messages_valid (messages); + notmuch_messages_move_to_next (messages)) { + sp->begin_list (sp); + sp->begin_list (sp); + + message = notmuch_messages_get (messages); + + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, TRUE); + excluded = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED); + + if (!excluded || !params->omit_excluded) { + status = show_message (ctx, format, sp, message, 0, params); + if (status && !res) + res = status; + } else { + sp->null (sp); + } + notmuch_message_destroy (message); + sp->end (sp); + sp->end (sp); + } + sp->end (sp); + return res; +} + enum { NOTMUCH_FORMAT_NOT_SPECIFIED, NOTMUCH_FORMAT_JSON, @@ -1168,6 +1212,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) bool exclude = true; bool entire_thread_set = false; bool single_message; + bool unthreaded = FALSE; notmuch_opt_desc_t options[] = { { .opt_keyword = &format, .name = "format", .keywords = @@ -1181,6 +1226,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) { .opt_bool = &exclude, .name = "exclude" }, { .opt_bool = ¶ms.entire_thread, .name = "entire-thread", .present = &entire_thread_set }, + { .opt_bool = &unthreaded, .name = "unthreaded" }, { .opt_int = ¶ms.part, .name = "part" }, { .opt_keyword = (int *) (¶ms.crypto.decrypt), .name = "decrypt", .keyword_no_arg_value = "true", .keywords = @@ -1317,7 +1363,10 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) params.omit_excluded = false; } - ret = do_show (config, query, formatter, sprinter, ¶ms); + if (unthreaded) + ret = do_show_unthreaded (config, query, formatter, sprinter, ¶ms); + else + ret = do_show_threaded (config, query, formatter, sprinter, ¶ms); } DONE: -- 2.11.0