From 7e72bef48f6fcfa05c7097aeeff9fc90f21a3085 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 30 Jun 2012 08:23:44 +0100 Subject: [PATCH] [PATCH] cli: notmuch-show with framing newlines between threads in JSON. --- a0/69ec2d12dd55a16bc3fd4f37e6262290c2a349 | 128 ++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 a0/69ec2d12dd55a16bc3fd4f37e6262290c2a349 diff --git a/a0/69ec2d12dd55a16bc3fd4f37e6262290c2a349 b/a0/69ec2d12dd55a16bc3fd4f37e6262290c2a349 new file mode 100644 index 000000000..0879c678d --- /dev/null +++ b/a0/69ec2d12dd55a16bc3fd4f37e6262290c2a349 @@ -0,0 +1,128 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 51EEA431FAE + for ; Sat, 30 Jun 2012 00:24:02 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id qCWaC9DAEtfE for ; + Sat, 30 Jun 2012 00:24:01 -0700 (PDT) +Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com + [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id A618B431FAF + for ; Sat, 30 Jun 2012 00:24:01 -0700 (PDT) +Received: by wibhm2 with SMTP id hm2so1501843wib.2 + for ; Sat, 30 Jun 2012 00:23:59 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer; + bh=bj9auI4c99c2jjXN2KghHX5PhZ1XJl/5exjRJttGWdI=; + b=OjVeteWabUmHFHiaMCR2E9f+5iqXFI+dgy2sCmfpu48Zjb/2SIb/ZY+ksUj/CguEg3 + pxdf4A/KsBCEZjFv181dR3lLKtd8tx7Dz5aj4V0SxlXOdKA6X5CSpN030I2ajmKuQcoK + ne/0PcvsZL7iIcqUzV4v2u/+eI+7P0kKxk3ei1LnDf3l03PoOlZqJYQz6LIGw20NYFGX + qHbpvgfcjPDn6ZFcNxHvXzwk/Qis89QfVGRdPhLCRhKwdIc82gxdBM5woAg0XmhcJ4yI + UkzIZ/dezwtpxtVlcRsM/il7bLJUAzGQUQEBYiJ/4ZJW9alSzuletDCWCQ/ApskXN3RI + 2TRg== +Received: by 10.180.105.135 with SMTP id gm7mr9919542wib.10.1341041039017; + Sat, 30 Jun 2012 00:23:59 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + eu4sm10324184wib.2.2012.06.30.00.23.56 (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 30 Jun 2012 00:23:57 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH] cli: notmuch-show with framing newlines between threads in + JSON. +Date: Sat, 30 Jun 2012 08:23:44 +0100 +Message-Id: <1341041024-5342-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 30 Jun 2012 07:24:02 -0000 + +Add newlines between complete threads to make asynchronous parsing +of the JSON easier. +--- + +notmuch-pick uses the JSON output of notmuch show but, in many cases, +for many threads. This can take quite a long time when displaying a +large number of messages (say 20 seconds for the 10,000 messages in +the notmuch archive). Thus it is desirable to display results +incrementally in the same way that search currently does. + +To make this easier this patch adds newlines between each toplevel +thread. So the ouput becomes + +[ +thread1 +, thread2 +, thread3 +... +, last_thread +] + +Thus the parser can easily tell if it has enough data to do some more +parsing. + +Obviously, this changes the JSON output. This should not break any +consumer as the JSON parsers should not mind. However, it does break +several tests. Obviously, I will fix these but I wanted to check if +people were basically happy with the change first. + +Also, should devel/schemata be updated? It seems a little unclear as +this is not really a "JSON" change as the JSON does not care about the +newlines. + +Best wishes + +Mark + + + notmuch-show.c | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/notmuch-show.c b/notmuch-show.c +index 195e318..4a1d699 100644 +--- a/notmuch-show.c ++++ b/notmuch-show.c +@@ -942,6 +942,8 @@ do_show (void *ctx, + + if (format->message_set_start) + fputs (format->message_set_start, stdout); ++ if (format == &format_json) ++ fputs ("\n", stdout); + + for (threads = notmuch_query_search_threads (query); + notmuch_threads_valid (threads); +@@ -963,6 +965,9 @@ do_show (void *ctx, + if (status && !res) + res = status; + ++ if (format == &format_json) ++ fputs ("\n", stdout); ++ + notmuch_thread_destroy (thread); + + } +-- +1.7.9.1 + -- 2.26.2