--- /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 9AC3F431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Jul 2012 22:30:38 -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 hkw0yIYq79jM for <notmuch@notmuchmail.org>;\r
+ Sat, 7 Jul 2012 22:30:38 -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 D3952431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 7 Jul 2012 22:30:37 -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 1Snk4l-0004hA-UI; Sun, 08 Jul 2012 06:30:32 +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 1Snk4l-0002bq-E5; Sun, 08 Jul 2012 06:30:31 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, Tomi Ollila <tomi.ollila@iki.fi>\r
+Subject: Re: [PATCH] cli: notmuch-show with framing newlines between threads\r
+ in JSON.\r
+In-Reply-To: <20120702035241.GD6220@mit.edu>\r
+References: <1341041024-5342-1-git-send-email-markwalters1009@gmail.com>\r
+ <m24npr8701.fsf@guru.guru-group.fi>\r
+ <20120702001215.GC6220@mit.edu> <20120702035241.GD6220@mit.edu>\r
+User-Agent: Notmuch/0.13.2+61~gf708609 (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sun, 08 Jul 2012 06:30:28 +0100\r
+Message-ID: <87ehomu8ej.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: 41df64e922ed6acb98993a710cf53d02 (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
+Cc: notmuch@notmuchmail.org\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, 08 Jul 2012 05:30:38 -0000\r
+\r
+On Mon, 02 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> Quoth myself on Jul 01 at 8:12 pm:\r
+>> Quoth Tomi Ollila on Jul 02 at 1:13 am:\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
+>> Given a JSON parser that only knows how to parse complete JSON\r
+>> expressions, it's potentially very inefficient to keep attempting to\r
+>> parse something when you don't know if it's complete. The newlines\r
+>> provide an in-band framing so the consumer knows when there's a\r
+>> complete object to be parsed.\r
+>> \r
+>> In effect, this defines a super-protocol of JSON that's compatible\r
+>> with standard JSON, but easy to incrementally parse.\r
+>> \r
+>> That said, just this weekend I implemented JSON-based search with\r
+>> incremental JSON parsing and I took a slightly different approach. I\r
+>> still put framing into the newlines of the search results, but rather\r
+>> than rely on it for correctness, the consumer uses it as an\r
+>> optimization that only hints that a complete JSON expression is\r
+>> probably available. If the expression turns out to be incomplete,\r
+>> that's okay.\r
+>> \r
+>> I considered building a fully-incremental JSON parser that never\r
+>> backtracks by more than a token, which would eliminate even the cost\r
+>> of reparsing, but if we do move to S-expressions (which I think we\r
+>> should), we want to let Emacs' C implementation do as much of the\r
+>> parsing as possible, and the only thing we can do with that is read a\r
+>> complete expression.\r
+>\r
+> Actually, I take that back. While we can't do fast incremental\r
+> S-expression parsing, `parse-partial-sexp' can tell us incrementally\r
+> (and probably very quickly) *if* there's a complete expression ready\r
+> to parse, so we could avoid calling into the parser at all unless it\r
+> would succeed.\r
+>\r
+> I'll try this out in my incremental JSON parser and see how well it\r
+> works.\r
+\r
+I have converted pick to use Austin's incremental parser and all works\r
+well so this seems the way to go. Hence I have marked my original patch\r
+obsolete.\r
+\r
+Best wishes\r
+\r
+Mark\r