From: Mark Walters Date: Mon, 13 Feb 2012 01:20:07 +0000 (+0000) Subject: [RFC PATCH v3 03/11] cli: add --thread= option to notmuch-show X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=e04965583e193e5de930faf205b8011e54769a74;p=notmuch-archives.git [RFC PATCH v3 03/11] cli: add --thread= option to notmuch-show --- diff --git a/32/007b55ca8482fdc26272c6b3f80a066b5b48e3 b/32/007b55ca8482fdc26272c6b3f80a066b5b48e3 new file mode 100644 index 000000000..298c6a220 --- /dev/null +++ b/32/007b55ca8482fdc26272c6b3f80a066b5b48e3 @@ -0,0 +1,216 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id D78EA421174 + for ; Sun, 12 Feb 2012 17:19:22 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id nYMRwCAY+fSo for ; + Sun, 12 Feb 2012 17:19:20 -0800 (PST) +Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com + [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 8AFF442117B + for ; Sun, 12 Feb 2012 17:19:17 -0800 (PST) +Received: by mail-wi0-f181.google.com with SMTP id hi8so3615406wib.26 + for ; Sun, 12 Feb 2012 17:19:17 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=HqIfNrUBY9HvmgZu0a+lYX/9AKyAG6MVNdwQdgCOG2w=; + b=ZVdS31dPC/rZxihLvBXHKoO2r2KL0RDlE0pwZzBll6K+OAPllKR7qQGWxT5QnE3zMZ + PThzjO1R5SoP2upRgvD2Ww7WNs7jJqh5e0fjwj0plI+zrc4Z27W+pz3iAsipazhqzlnX + EZoNX9d3QT5h+UUeEf5Qg8/iM2arkfkHBsIPA= +Received: by 10.216.132.94 with SMTP id n72mr5485613wei.4.1329095957266; + Sun, 12 Feb 2012 17:19:17 -0800 (PST) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + dr5sm41857437wib.0.2012.02.12.17.19.15 (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 12 Feb 2012 17:19:16 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [RFC PATCH v3 03/11] cli: add --thread= option to notmuch-show +Date: Mon, 13 Feb 2012 01:20:07 +0000 +Message-Id: <1329096015-8078-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.2.3 +In-Reply-To: <1329072579-27340-1-git-send-email-markwalters1009@gmail.com> +References: <1329072579-27340-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Mon, 13 Feb 2012 01:19:23 -0000 + +The possible values are --thread=none|entire|match. + +`entire' is exactly the existing option --entire-thread. + +`match' is exactly the existing case when --entire-thread is not specified. + +`none' is a new option to return just the matching messages with no +threading information at all. + +The `none' option is used by notmuch-pick.el to display an unthreaded +message view (e.g., for an inbox). It is also useful for displaying a +single message in the notmuch-pick view as show/emacs is much faster at +showing a single message than the whole thread. + +The default remains as before: `match' in all cases except when +--format=json is specified when `entire' is used. +--- + notmuch-client.h | 8 ++++++- + notmuch-show.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 64 insertions(+), 4 deletions(-) + +diff --git a/notmuch-client.h b/notmuch-client.h +index 0da2d8d..b4dc7bf 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -97,8 +97,14 @@ typedef struct notmuch_show_format { + const char *message_set_end; + } notmuch_show_format_t; + ++enum { ++ NOTMUCH_SHOW_THREAD_MATCH, ++ NOTMUCH_SHOW_THREAD_ENTIRE, ++ NOTMUCH_SHOW_THREAD_NONE ++}; ++ + typedef struct notmuch_show_params { +- notmuch_bool_t entire_thread; ++ int entire_thread; + notmuch_bool_t raw; + int part; + int headers_only; +diff --git a/notmuch-show.c b/notmuch-show.c +index 8f6e520..3f8618b 100644 +--- a/notmuch-show.c ++++ b/notmuch-show.c +@@ -893,13 +893,56 @@ show_messages (void *ctx, + notmuch_message_get_replies (message), + next_indent, + params); ++ notmuch_message_destroy (message); ++ ++ fputs (format->message_set_end, stdout); ++ } ++ ++ fputs (format->message_set_end, stdout); ++} ++ ++static int ++do_show_messages (void *ctx, ++ notmuch_query_t *query, ++ const notmuch_show_format_t *format, ++ notmuch_show_params_t *params) ++{ ++ notmuch_messages_t *messages; ++ notmuch_message_t *message; ++ int first_set = 1; ++ ++ fputs (format->message_set_start, stdout); ++ messages = notmuch_query_search_messages (query); ++ ++ for (; ++ notmuch_messages_valid (messages); ++ notmuch_messages_move_to_next (messages)) ++ { ++ if (!first_set) ++ fputs (format->message_set_sep, stdout); ++ first_set = 0; ++ ++ fputs (format->message_set_start, stdout); ++ fputs (format->message_set_start, stdout); ++ ++ message = notmuch_messages_get (messages); ++ notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, 1); ++ show_message (ctx, format, message, 0, params); ++ ++ fputs (format->message_set_sep, stdout); ++ ++ fputs (format->message_set_start, stdout); ++ fputs (format->message_set_end, stdout); ++ + + notmuch_message_destroy (message); + + fputs (format->message_set_end, stdout); ++ fputs (format->message_set_end, stdout); + } + + fputs (format->message_set_end, stdout); ++ return 0; + } + + /* Formatted output of single message */ +@@ -1030,6 +1073,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + notmuch_query_t *query; + char *query_string; + int opt_index, ret; ++ int entire_thread = NOTMUCH_SHOW_THREAD_MATCH; + notmuch_sort_t sort = NOTMUCH_SORT_NEWEST_FIRST; + const notmuch_show_format_t *format = &format_text; + notmuch_show_params_t params = { .part = -1 }; +@@ -1049,7 +1093,11 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + { "newest-first", NOTMUCH_SORT_NEWEST_FIRST }, + { 0, 0 } } }, + { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 }, +- { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 }, ++ { NOTMUCH_OPT_KEYWORD, &entire_thread, "thread", 't', ++ (notmuch_keyword_t []){ { "match", NOTMUCH_SHOW_THREAD_MATCH, }, ++ { "entire", NOTMUCH_SHOW_THREAD_ENTIRE }, ++ { "none", NOTMUCH_SHOW_THREAD_NONE }, ++ { 0, 0 } } }, + { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 }, + { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 }, + { NOTMUCH_OPT_BOOLEAN, &headers_only, "headers-only", 'h', 0 }, +@@ -1062,6 +1110,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + return 1; + } + ++ params.entire_thread = entire_thread; + params.headers_only = headers_only; + + if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) { +@@ -1075,7 +1124,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + switch (format_sel) { + case NOTMUCH_FORMAT_JSON: + format = &format_json; +- params.entire_thread = TRUE; ++ /* This may not still be wanted */ ++ if (params.entire_thread == NOTMUCH_SHOW_THREAD_MATCH) ++ params.entire_thread = NOTMUCH_SHOW_THREAD_ENTIRE; + break; + case NOTMUCH_FORMAT_TEXT: + format = &format_text; +@@ -1147,7 +1198,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + if (params.part >= 0) + ret = do_show_single (ctx, query, format, ¶ms); + else +- ret = do_show (ctx, query, format, ¶ms); ++ if (params.entire_thread == NOTMUCH_SHOW_THREAD_NONE) ++ ret = do_show_messages (ctx, query, format, ¶ms); ++ else ++ ret = do_show (ctx, query, format, ¶ms); + + notmuch_query_destroy (query); + notmuch_database_close (notmuch); +-- +1.7.2.3 +