[PATCH] cli: notmuch-show with framing newlines between threads in JSON.

Dmitry Kurochkin dmitry.kurochkin at gmail.com
Sat Jun 30 00:42:40 PDT 2012


Hi Mark.

Mark Walters <markwalters1009 at gmail.com> writes:

> 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.

I think this should be part of the commit message since it explains the
rationale behind the change.

Regards,
  Dmitry

> 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
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list