--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 37189431FBC\r
+ for <notmuch@notmuchmail.org>; Sun, 1 Jul 2012 15:44:10 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 s6NBfQvVZE0z for <notmuch@notmuchmail.org>;\r
+ Sun, 1 Jul 2012 15:44:09 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 1A4E2431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 1 Jul 2012 15:44:09 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1SlSs6-0005fW-2W; Sun, 01 Jul 2012 23:44:07 +0100\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+ helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1SlSs5-0001Uq-MY; Sun, 01 Jul 2012 23:44:01 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] cli: notmuch-show with framing newlines between threads\r
+ in JSON.\r
+In-Reply-To: <m24npr8701.fsf@guru.guru-group.fi>\r
+References: <1341041024-5342-1-git-send-email-markwalters1009@gmail.com>\r
+ <m24npr8701.fsf@guru.guru-group.fi>\r
+User-Agent: Notmuch/0.13.2+70~gb6a56e7 (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sun, 01 Jul 2012 23:43:57 +0100\r
+Message-ID: <8762a72jbm.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: ca11c5bc5f73be30bedae6124641d972 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -1.8 points.\r
+ Summary of the scoring: \r
+ * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+ * medium trust\r
+ * [138.37.6.40 listed in list.dnswl.org]\r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+ * domain\r
+ * 0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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: Sun, 01 Jul 2012 22:44:10 -0000\r
+\r
+On Sun, 01 Jul 2012, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
+> On Sat, Jun 30 2012, Mark Walters <markwalters1009@gmail.com> wrote:\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
+> To provide this feature rather than relying on newlines the parser should\r
+> use it's state to notice when one thread ends. \r
+>\r
+> Such a change could be used (privately) for human consumption -- allowing \r
+> free change of whitespace during inspection (in a debugging session or so).\r
+> Computer software should not rely (or suffer) from any additional\r
+> (or lack thereof) whitespace there is...\r
+>\r
+> ... or at least a really convicing argument for the chance needs to\r
+> be presented (before "restricting" the json output notmuch spits out).\r
+>\r
+> Btw: AFAIC (json-read) parses the whole json object (ignoring whitespace,\r
+> including newlines outside strings). So I quess notmuch-pick uses something\r
+> slightly different (probably using json.el subroutines)..\r
+\r
+I was following Austin's suggestion (on irc and\r
+id:"20120214152114.GQ27039@mit.edu"). The idea is that each thread in\r
+the JSON output is an entire JSON object. Thus pick skips the first [\r
+and the waits until there are two \n's in the incoming stream. Then it\r
+knows that the complete first thread has been received and it parses\r
+that with json-read as normal. The important thing is that it is trivial\r
+to tell when a complete (and so parsable) JSON object has arrived.\r
+\r
+It seems to work, but I am definitely open to other approaches.\r
+\r
+> Btw2: I'm very interested to see notmuch-pick in action -- I just don't\r
+> see this a way to do this particular support properly.\r
+>\r
+> Btw3: is search is ever going to use json we'll face the same problem -- \r
+> unless writing each line as a separate json object (and starting to use \r
+> s-expressions for speed)\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
+\r
+> and best luck with your notmuch-pick work.\r
+\r
+Thanks!\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
+>> _______________________________________________\r
+>> notmuch mailing list\r
+>> notmuch@notmuchmail.org\r
+>> http://notmuchmail.org/mailman/listinfo/notmuch\r