[PATCH] cli: notmuch-show with framing newlines between threads in JSON.
authorMark Walters <markwalters1009@gmail.com>
Sat, 30 Jun 2012 07:23:44 +0000 (08:23 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:54 +0000 (09:47 -0800)
a0/69ec2d12dd55a16bc3fd4f37e6262290c2a349 [new file with mode: 0644]

diff --git a/a0/69ec2d12dd55a16bc3fd4f37e6262290c2a349 b/a0/69ec2d12dd55a16bc3fd4f37e6262290c2a349
new file mode 100644 (file)
index 0000000..0879c67
--- /dev/null
@@ -0,0 +1,128 @@
+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 51EEA431FAE\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Jun 2012 00:24:02 -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 qCWaC9DAEtfE for <notmuch@notmuchmail.org>;\r
+       Sat, 30 Jun 2012 00:24:01 -0700 (PDT)\r
+Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com\r
+       [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A618B431FAF\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Jun 2012 00:24:01 -0700 (PDT)\r
+Received: by wibhm2 with SMTP id hm2so1501843wib.2\r
+       for <notmuch@notmuchmail.org>; Sat, 30 Jun 2012 00:23:59 -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;\r
+       bh=bj9auI4c99c2jjXN2KghHX5PhZ1XJl/5exjRJttGWdI=;\r
+       b=OjVeteWabUmHFHiaMCR2E9f+5iqXFI+dgy2sCmfpu48Zjb/2SIb/ZY+ksUj/CguEg3\r
+       pxdf4A/KsBCEZjFv181dR3lLKtd8tx7Dz5aj4V0SxlXOdKA6X5CSpN030I2ajmKuQcoK\r
+       ne/0PcvsZL7iIcqUzV4v2u/+eI+7P0kKxk3ei1LnDf3l03PoOlZqJYQz6LIGw20NYFGX\r
+       qHbpvgfcjPDn6ZFcNxHvXzwk/Qis89QfVGRdPhLCRhKwdIc82gxdBM5woAg0XmhcJ4yI\r
+       UkzIZ/dezwtpxtVlcRsM/il7bLJUAzGQUQEBYiJ/4ZJW9alSzuletDCWCQ/ApskXN3RI\r
+       2TRg==\r
+Received: by 10.180.105.135 with SMTP id gm7mr9919542wib.10.1341041039017;\r
+       Sat, 30 Jun 2012 00:23:59 -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
+ eu4sm10324184wib.2.2012.06.30.00.23.56        (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 30 Jun 2012 00:23:57 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] cli: notmuch-show with framing newlines between threads in\r
+       JSON.\r
+Date: Sat, 30 Jun 2012 08:23:44 +0100\r
+Message-Id: <1341041024-5342-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\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, 30 Jun 2012 07:24:02 -0000\r
+\r
+Add newlines between complete threads to make asynchronous parsing\r
+of the JSON easier.\r
+---\r
+\r
+notmuch-pick uses the JSON output of notmuch show but, in many cases,\r
+for many threads. This can take quite a long time when displaying a\r
+large number of messages (say 20 seconds for the 10,000 messages in\r
+the notmuch archive). Thus it is desirable to display results\r
+incrementally in the same way that search currently does.\r
+\r
+To make this easier this patch adds newlines between each toplevel\r
+thread. So the ouput becomes\r
+\r
+[\r
+thread1\r
+, thread2\r
+, thread3\r
+...\r
+, last_thread\r
+]\r
+\r
+Thus the parser can easily tell if it has enough data to do some more\r
+parsing.\r
+\r
+Obviously, this changes the JSON output. This should not break any\r
+consumer as the JSON parsers should not mind. However, it does break\r
+several tests. Obviously, I will fix these but I wanted to check if\r
+people were basically happy with the change first.\r
+\r
+Also, should devel/schemata be updated? It seems a little unclear as\r
+this is not really a "JSON" change as the JSON does not care about the\r
+newlines.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+ notmuch-show.c |    5 +++++\r
+ 1 files changed, 5 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 195e318..4a1d699 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -942,6 +942,8 @@ do_show (void *ctx,\r
\r
+     if (format->message_set_start)\r
+       fputs (format->message_set_start, stdout);\r
++    if (format == &format_json)\r
++      fputs ("\n", stdout);\r
\r
+     for (threads = notmuch_query_search_threads (query);\r
+        notmuch_threads_valid (threads);\r
+@@ -963,6 +965,9 @@ do_show (void *ctx,\r
+       if (status && !res)\r
+           res = status;\r
\r
++      if (format == &format_json)\r
++          fputs ("\n", stdout);\r
++\r
+       notmuch_thread_destroy (thread);\r
\r
+     }\r
+-- \r
+1.7.9.1\r
+\r