[PATCH v5 2/5] cli: Let json output "null" messages for non --entire-thread
authorMark Walters <markwalters1009@gmail.com>
Sat, 26 May 2012 15:54:51 +0000 (16:54 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:26 +0000 (09:47 -0800)
b4/296bbbb2812f8196434cae34456535897fb056 [new file with mode: 0644]

diff --git a/b4/296bbbb2812f8196434cae34456535897fb056 b/b4/296bbbb2812f8196434cae34456535897fb056
new file mode 100644 (file)
index 0000000..703dab8
--- /dev/null
@@ -0,0 +1,134 @@
+Return-Path: <markwalters1009@gmail.com>\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 39335429E26\r
+       for <notmuch@notmuchmail.org>; Sat, 26 May 2012 08:55:17 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       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 PLLT0aUZu1QY for <notmuch@notmuchmail.org>;\r
+       Sat, 26 May 2012 08:55:16 -0700 (PDT)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 076E1431FBC\r
+       for <notmuch@notmuchmail.org>; Sat, 26 May 2012 08:55:07 -0700 (PDT)\r
+Received: by mail-we0-f181.google.com with SMTP id j55so1411304wer.26\r
+       for <notmuch@notmuchmail.org>; Sat, 26 May 2012 08:55:07 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=mfd1W0o3Zq5XgbruG4RMp4PSq5smW6eg4We84NNSXOc=;\r
+       b=qzpmttOiwpFAJfbGznpYJtzFIfMwGo1UmihV6gU2FJnn5fHVXNbTWe694h1iMuiiqc\r
+       hGNW+pt2Y0a9hAyQOvhBxDG6fDiuimqcoKer19PBk/arPc5HUAngR/1n73fdyO0r39Y6\r
+       1k6WG7BoSLnDwiYayidjHgzA1Drw7CWx4w4os02zgGfMmgMgOXnx5K/dRFbODMvGjJ39\r
+       SMFMwZbk9OuaF+bJ6sV+B76FxSl8NiVhYE0RicRjUh9T8wAs15CHEL9Bgv/tQymaB8tg\r
+       9BXjn0NGYbqe4lPV1J1kT73Fl6XDC/lno8gL68YH3XSHFWpyG6/T6Cnkh7FVMZ6vYbIO\r
+       akyg==\r
+Received: by 10.180.80.35 with SMTP id o3mr4227774wix.7.1338047707621;\r
+       Sat, 26 May 2012 08:55:07 -0700 (PDT)\r
+Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
+ [94.192.233.223])     by mx.google.com with ESMTPS id\r
+ fl2sm9297732wib.2.2012.05.26.08.55.06 (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 26 May 2012 08:55:07 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v5 2/5] cli: Let json output "null" messages for non\r
+       --entire-thread\r
+Date: Sat, 26 May 2012 16:54:51 +0100\r
+Message-Id: <1338047694-32548-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1338047694-32548-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1338047694-32548-1-git-send-email-markwalters1009@gmail.com>\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, 26 May 2012 15:55:17 -0000\r
+\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 19b7f01..08540a7 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -72,6 +72,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_show_params {\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 95427d4..97da5cc 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
+@@ -862,11 +872,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