From a5bbc92c66f39b918aa67fe97ee6231ef7105517 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 24 Jun 2012 11:19:25 +2000 Subject: [PATCH] Re: [Patch v8 2/6] cli: Let json output "null" messages for non --entire-thread --- 03/173561d5026867bb83f8cf819c3e435a0d3339 | 155 ++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 03/173561d5026867bb83f8cf819c3e435a0d3339 diff --git a/03/173561d5026867bb83f8cf819c3e435a0d3339 b/03/173561d5026867bb83f8cf819c3e435a0d3339 new file mode 100644 index 000000000..076c9c5f7 --- /dev/null +++ b/03/173561d5026867bb83f8cf819c3e435a0d3339 @@ -0,0 +1,155 @@ +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 47D5F431FC0 + for ; Sat, 23 Jun 2012 08:19:29 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 T5Ib8krcOilx for ; + Sat, 23 Jun 2012 08:19:28 -0700 (PDT) +Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU + [18.7.68.37]) + by olra.theworths.org (Postfix) with ESMTP id 2EB7E431FAF + for ; Sat, 23 Jun 2012 08:19:28 -0700 (PDT) +X-AuditID: 12074425-b7f9b6d0000008c4-df-4fe5de7f20dd +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP + id 97.45.02244.F7ED5EF4; Sat, 23 Jun 2012 11:19:27 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q5NFJQ50010122; + Sat, 23 Jun 2012 11:19:27 -0400 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q5NFJPiY025537 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 23 Jun 2012 11:19:26 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1SiS7R-0005JJ-I9; Sat, 23 Jun 2012 11:19:25 -0400 +From: Austin Clements +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [Patch v8 2/6] cli: Let json output "null" messages for non + --entire-thread +In-Reply-To: <1339842107-10632-3-git-send-email-markwalters1009@gmail.com> +References: <1339842107-10632-1-git-send-email-markwalters1009@gmail.com> + <1339842107-10632-3-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.12+132~gf2f390b (http://notmuchmail.org) Emacs/23.3.1 + (i486-pc-linux-gnu) +Date: Sat, 23 Jun 2012 11:19:25 -0400 +Message-ID: <87vcii12f6.fsf@awakening.csail.mit.edu> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsUixCmqrFt/76m/wauzuhar5/JYXL85k9mB + yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyuh6KV6wQKTi5e0VzA2MT/i7GDk5JARMJO59 + PswCYYtJXLi3nq2LkYtDSGAfo8Tkv23MEM4GRolPLX2MEM5JJonXtzqhMksYJeb+m80E0s8m + oCGxbf9yRhBbRMBV4um3z8wgtrBAhMT17dPYuxg5ODgFvCQO7gwECQsJtDNKTFrJCWKLCsRL + /OndzAZiswioSmxfeAhsJC/QeWtnT2WDsAUlTs58AnYqs4CWxI1/L5kmMArMQpKahSS1gJFp + FaNsSm6Vbm5iZk5xarJucXJiXl5qka6FXm5miV5qSukmRlA4sruo7mCccEjpEKMAB6MSD++r + ZU/8hVgTy4orcw8xSnIwKYnyat996i/El5SfUpmRWJwRX1Sak1p8iFGCg1lJhHcqSI43JbGy + KrUoHyYlzcGiJM57I+Wmv5BAemJJanZqakFqEUxWhoNDSYL3IUijYFFqempFWmZOCUKaiYMT + ZDgP0PD5YMOLCxJzizPTIfKnGBWlxHl3gCQEQBIZpXlwvbB08YpRHOgVYd47IFU8wFQD1/0K + aDAT0GBOhscgg0sSEVJSDYxZhuJ555puGgp4TlvLUX/CYJUjy3Km+uCbP6Yx79k3N//8D8+O + WS2nTD880rVdX3zmYMrkq62+Mn/Nmc5G26Xq9aeXpG1rO145f5psnEVCmOsJ403tE+PeaKqe + yVuy5IqJE9+OjVUBbbI/ejp+cExcoel66GrK4iV3p3WtmTCVV6cvXdHncpwSS3FGoqEWc1Fx + IgBUvNPk8gIAAA== +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, 23 Jun 2012 15:19:29 -0000 + +The JSON format change LGTM. This seems like the right way to do this. + +On Sat, 16 Jun 2012, Mark Walters wrote: +> All formats except Json can output empty messages for non +> entire-thread, but in Json format we output "null" to keep the other +> elements (e.g. the replies to the omitted message) in the correct +> place. +> --- +> notmuch-client.h | 1 + +> notmuch-show.c | 20 ++++++++++++++++---- +> 2 files changed, 17 insertions(+), 4 deletions(-) +> +> diff --git a/notmuch-client.h b/notmuch-client.h +> index 9b63eae..0c17b79 100644 +> --- a/notmuch-client.h +> +++ b/notmuch-client.h +> @@ -75,6 +75,7 @@ typedef struct notmuch_show_format { +> const struct notmuch_show_params *params); +> const char *message_set_sep; +> const char *message_set_end; +> + const char *null_message; +> } notmuch_show_format_t; +> +> typedef struct notmuch_crypto { +> diff --git a/notmuch-show.c b/notmuch-show.c +> index 8247f1d..b004468 100644 +> --- a/notmuch-show.c +> +++ b/notmuch-show.c +> @@ -37,7 +37,8 @@ static const notmuch_show_format_t format_json = { +> .message_set_start = "[", +> .part = format_part_json_entry, +> .message_set_sep = ", ", +> - .message_set_end = "]" +> + .message_set_end = "]", +> + .null_message = "null" +> }; +> +> static notmuch_status_t +> @@ -800,6 +801,15 @@ format_part_raw (unused (const void *ctx), mime_node_t *node, +> } +> +> static notmuch_status_t +> +show_null_message (const notmuch_show_format_t *format) +> +{ +> + /* Output a null message. Currently empty for all formats except Json */ +> + if (format->null_message) +> + printf ("%s", format->null_message); +> + return NOTMUCH_STATUS_SUCCESS; +> +} +> + +> +static notmuch_status_t +> show_message (void *ctx, +> const notmuch_show_format_t *format, +> notmuch_message_t *message, +> @@ -861,11 +871,13 @@ show_messages (void *ctx, +> if (status && !res) +> res = status; +> next_indent = indent + 1; +> - +> - if (!status && format->message_set_sep) +> - fputs (format->message_set_sep, stdout); +> + } else { +> + status = show_null_message (format); +> } +> +> + if (!status && format->message_set_sep) +> + fputs (format->message_set_sep, stdout); +> + +> status = show_messages (ctx, +> format, +> notmuch_message_get_replies (message), +> -- +> 1.7.9.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2