From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id BD355431FBC for ; Sat, 26 May 2012 08:55:19 -0700 (PDT) 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 iTMNuBYELESP for ; Sat, 26 May 2012 08:55:18 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 52FFD429E48 for ; Sat, 26 May 2012 08:55:14 -0700 (PDT) Received: by wibhn14 with SMTP id hn14so419591wib.2 for ; Sat, 26 May 2012 08:55:13 -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:x-mailer:in-reply-to:references; bh=uW9UzMUuW4RvL6HwveBZfKownUyZ/BrTGlBS2m1565g=; b=qVR5/jTnaNnbA6NU8D/QdE81MZMWWQDsA3YKJCiKY+cok4xwRZVqHOjulq2kpUgQKx gNvZ6GXXP8/2Skrm+tBRR0XlAHsMXi8cjzmG2s0QGlH7V2DbXqDi+uP2Dgjfl5OfFcYv qMN24jPSw7PwOcxfqfqhFcbd6e1bn08oMCHibxGl54yY4ZwPog8jz0jlXa46mJ3r2X10 cv1ip7hLG1gh1uXmHwIjYlfgBf5egZiwqms6C2ihrUezW6m5XGEAB2bgxBpqDqHziqXE 88F3MdtvOQPqV8SgW2mPHDIX6iyDB52vB+NiQAzfFIribX8AkyJrv2RvC0nYJj2TGznV MrRg== Received: by 10.216.202.160 with SMTP id d32mr1393338weo.147.1338047709926; Sat, 26 May 2012 08:55:09 -0700 (PDT) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id e20sm5907028wiv.7.2012.05.26.08.55.08 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 08:55:09 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v5 3/5] cli: make --entire-thread=false work for format=json. Date: Sat, 26 May 2012 16:54:52 +0100 Message-Id: <1338047694-32548-4-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1338047694-32548-1-git-send-email-markwalters1009@gmail.com> References: <1338047694-32548-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: Sat, 26 May 2012 15:55:20 -0000 The --entire-thread option in notmuch-show.c defaults to true when format=json. Previously there was no way to turn this off. This patch makes it respect --entire-thread=false. To do this the patch moves the --entire-thread option to be a keyword option using the new command line parsing to allow the existing --entire-thread syntax to keep working. --- notmuch-show.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 97da5cc..207093a 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -981,6 +981,12 @@ enum { NOTMUCH_FORMAT_RAW }; +enum { + ENTIRE_THREAD_DEFAULT, + ENTIRE_THREAD_TRUE, + ENTIRE_THREAD_FALSE, +}; + /* The following is to allow future options to be added more easily */ enum { EXCLUDE_TRUE, @@ -1000,6 +1006,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; notmuch_bool_t verify = FALSE; int exclude = EXCLUDE_TRUE; + int entire_thread = ENTIRE_THREAD_DEFAULT; notmuch_opt_desc_t options[] = { { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f', @@ -1012,8 +1019,11 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) (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 }, + { 0, 0 } } }, { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 }, - { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 }, { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 }, { 0, 0, 0, 0, 0 } @@ -1036,7 +1046,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; + /* JSON defaults to entire-thread TRUE */ + if (entire_thread == ENTIRE_THREAD_DEFAULT) + entire_thread = ENTIRE_THREAD_TRUE; break; case NOTMUCH_FORMAT_TEXT: format = &format_text; @@ -1058,6 +1070,15 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) params.raw = TRUE; break; } + /* Default is entire-thread = FALSE except for format=json which + * is dealt with above. */ + if (entire_thread == ENTIRE_THREAD_DEFAULT) + entire_thread = ENTIRE_THREAD_FALSE; + + if (entire_thread == ENTIRE_THREAD_TRUE) + params.entire_thread = TRUE; + else + params.entire_thread = FALSE; if (params.decrypt || verify) { #ifdef GMIME_ATLEAST_26 -- 1.7.9.1