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 00D10431FAE for ; Sat, 16 Jun 2012 03:22:13 -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 86kOd9JPlbYQ for ; Sat, 16 Jun 2012 03:22:11 -0700 (PDT) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 47A8A431FCF for ; Sat, 16 Jun 2012 03:22:08 -0700 (PDT) Received: by mail-wi0-f179.google.com with SMTP id hr14so238325wib.2 for ; Sat, 16 Jun 2012 03:22:07 -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=s+K/A5VU6DPsCLRem49ri3nT4RSNbfhwZZZ56f1a5/I=; b=urI2tUpUojtib/OqtlYfh0SrEjAJ+5+iVFNabHN2UmGKqHVjzQbIV6HnyJI+XK5fih /rvzFhmRj88Ny1yND6kIgQw6NPbRIAHFor1wQa9vGY3CCnAkRassJA4fM4oIjarjx3Cl 9dUxXLt3H0mneSiKlPMmOLuyWm/be0hCP2z7EkrLbDRuUx3XGM4mdophFtWugIIYVCWc fWsl2bejb5IDfhSHd06ed7r2yem/XvIpTzC1a/oY3F7Go0XPbirnpS+2hQp3mdxa9u2n A+xsv/Hjltqk4JbYebHeHWU9dO62ozdQEKe80u4IGBu24q4HD2ww6GblhMDw+LRoi0BX 0rrw== Received: by 10.216.141.31 with SMTP id f31mr4721990wej.53.1339842127833; Sat, 16 Jun 2012 03:22:07 -0700 (PDT) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id f7sm16608244wiv.2.2012.06.16.03.22.06 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 16 Jun 2012 03:22:06 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [Patch v8 3/6] cli: make --entire-thread=false work for format=json. Date: Sat, 16 Jun 2012 11:21:44 +0100 Message-Id: <1339842107-10632-4-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1339842107-10632-1-git-send-email-markwalters1009@gmail.com> References: <1339842107-10632-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, 16 Jun 2012 10:22:13 -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 to keep working. --- notmuch-show.c | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index b004468..e6eb625 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -980,6 +980,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, @@ -1005,6 +1011,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) }; int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED; int exclude = EXCLUDE_TRUE; + int entire_thread = ENTIRE_THREAD_DEFAULT; notmuch_opt_desc_t options[] = { { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f', @@ -1017,8 +1024,12 @@ 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 }, + { "", ENTIRE_THREAD_TRUE }, + { 0, 0 } } }, { NOTMUCH_OPT_INT, ¶ms.part, "part", 'p', 0 }, - { NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.decrypt, "decrypt", 'd', 0 }, { NOTMUCH_OPT_BOOLEAN, ¶ms.crypto.verify, "verify", 'v', 0 }, { 0, 0, 0, 0, 0 } @@ -1045,7 +1056,6 @@ 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; break; case NOTMUCH_FORMAT_TEXT: format = &format_text; @@ -1068,6 +1078,19 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) break; } + /* Default is entire-thread = FALSE except for format=json. */ + if (entire_thread == ENTIRE_THREAD_DEFAULT) { + if (format == &format_json) + entire_thread = ENTIRE_THREAD_TRUE; + else + entire_thread = ENTIRE_THREAD_FALSE; + } + + if (entire_thread == ENTIRE_THREAD_TRUE) + params.entire_thread = TRUE; + else + params.entire_thread = FALSE; + config = notmuch_config_open (ctx, NULL, NULL); if (config == NULL) return 1; -- 1.7.9.1