Re: [PATCH] cli: notmuch-show with framing newlines between threads in JSON.
authorTomi Ollila <tomi.ollila@iki.fi>
Sun, 1 Jul 2012 22:13:34 +0000 (01:13 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:56 +0000 (09:47 -0800)
77/d0931eb4a563d1de0a5e1fa7b303bc367bfa96 [new file with mode: 0644]

diff --git a/77/d0931eb4a563d1de0a5e1fa7b303bc367bfa96 b/77/d0931eb4a563d1de0a5e1fa7b303bc367bfa96
new file mode 100644 (file)
index 0000000..13299c5
--- /dev/null
@@ -0,0 +1,151 @@
+Return-Path: <tomi.ollila@iki.fi>\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 79731431FBC\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Jul 2012 15:13:27 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 aYiPhJPCvnTm for <notmuch@notmuchmail.org>;\r
+       Sun,  1 Jul 2012 15:13:26 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 20ECB431FAF\r
+       for <notmuch@notmuchmail.org>; Sun,  1 Jul 2012 15:13:26 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id A761B100637; Mon,  2 Jul 2012 01:13:34 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] cli: notmuch-show with framing newlines between threads\r
+       in JSON.\r
+In-Reply-To: <1341041024-5342-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1341041024-5342-1-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.13.2+7~g2fb5bbc (http://notmuchmail.org) Emacs/23.1.1\r
+       (x86_64-redhat-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Mon, 02 Jul 2012 01:13:34 +0300\r
+Message-ID: <m24npr8701.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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:13:27 -0000\r
+\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
+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
+and best luck with your notmuch-pick work.\r
+\r
+>\r
+> Mark\r
+\r
+Tomi\r
+\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