From: Peter Wang Date: Mon, 28 May 2012 13:34:15 +0000 (+1000) Subject: Re: [PATCH v6 3/6] cli: make --entire-thread=false work for format=json. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=b9c4e36c938f307dc40f01bf007e1b58e6b49cec;p=notmuch-archives.git Re: [PATCH v6 3/6] cli: make --entire-thread=false work for format=json. --- diff --git a/5a/ba45075e4fbfa911cd245bc04c966216e4c2ad b/5a/ba45075e4fbfa911cd245bc04c966216e4c2ad new file mode 100644 index 000000000..98f252819 --- /dev/null +++ b/5a/ba45075e4fbfa911cd245bc04c966216e4c2ad @@ -0,0 +1,107 @@ +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 3BB00431FAF + for ; Mon, 28 May 2012 06:34:23 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.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 3EsQqmdlqiWK for ; + Mon, 28 May 2012 06:34:22 -0700 (PDT) +Received: from mail-pz0-f53.google.com (mail-pz0-f53.google.com + [209.85.210.53]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id BBCF9431FAE + for ; Mon, 28 May 2012 06:34:22 -0700 (PDT) +Received: by dadg9 with SMTP id g9so5244481dad.26 + for ; Mon, 28 May 2012 06:34:22 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=date:message-id:from:to:subject:in-reply-to:references:mime-version + :content-type:content-disposition:content-transfer-encoding; + bh=tWYS108PeGbYv17E7oyn2F1/gCzCjh4vNMuAw4T0Nvk=; + b=WIGVe9JZtqRY0Oyyk7Fd/q+QJcFCIesWTtAmQ+paf5TCL9X0RCOuhHJkFpRVr/cQVT + 8NufsEUO1zDEdD+0S1CE0BYfJy8Tvq2TsSGgKvo4avweB/GNydO0sgeIVmapI5y6JQxb + YGBUAXpPGkkAHz1ZFdv6fNraeBCLw8jJkT3NMMXDkAAv/HUHbkPkaGawATqrxdAgYGDS + O8smNJx01t+mM/gw+WGAaKgJxFNeBhp05I92k1cITymknwAPAbGvEqYiCJrLLj6NQFH2 + Iyzvl65V7X5gmb7F6wbsN4nXLixGT1+mTaXO/wyOkd6IPbtd+WF/rOnXK1LUnsHEgAS7 + keUQ== +Received: by 10.68.231.164 with SMTP id th4mr27399887pbc.97.1338212061952; + Mon, 28 May 2012 06:34:21 -0700 (PDT) +Received: from localhost (215.42.233.220.static.exetel.com.au. + [220.233.42.215]) + by mx.google.com with ESMTPS id ve6sm19291964pbc.75.2012.05.28.06.34.18 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 28 May 2012 06:34:20 -0700 (PDT) +Date: Mon, 28 May 2012 23:34:15 +1000 +Message-ID: <20120528233415.GE2331@hili.localdomain> +From: Peter Wang +To: notmuch@notmuchmail.org +Subject: Re: [PATCH v6 3/6] cli: make --entire-thread=false work for + format=json. +In-Reply-To: <1338106946-7611-4-git-send-email-markwalters1009@gmail.com> +References: <1338106946-7611-1-git-send-email-markwalters1009@gmail.com> + <1338106946-7611-4-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +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, 28 May 2012 13:34:23 -0000 + +On Sun, 27 May 2012 09:22:23 +0100, Mark Walters wrote: +> @@ -1036,7 +1047,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; + +Minor point, but you can defer this until later and keep the logic in +one place. + +> case NOTMUCH_FORMAT_TEXT: +> format = &format_text; +> @@ -1058,6 +1071,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; + + /* 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; + } + +Peter