Re: [Patch v8 2/6] cli: Let json output "null" messages for non --entire-thread
authorAustin Clements <amdragon@MIT.EDU>
Sat, 23 Jun 2012 15:19:25 +0000 (11:19 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:46 +0000 (09:47 -0800)
03/173561d5026867bb83f8cf819c3e435a0d3339 [new file with mode: 0644]

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