[Patch v2] Minor correction to devel/schemata

2012-06-30 Thread Austin Clements
LGTM.

On Sat, 30 Jun 2012, Mark Walters  wrote:
> In id:"87sjdm12d1.fsf at awakening.csail.mit.edu" Austin pointed out that
> devel/schemata needs a slight correction with the new
> --entire-thread=false option. This is that correction.
>
> ---
>
> Resend with better commit message
>
> Best wishes
>
> Mark
>
>  devel/schemata |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/devel/schemata b/devel/schemata
> index 8fcab8e..f7e1b69 100644
> --- a/devel/schemata
> +++ b/devel/schemata
> @@ -32,7 +32,7 @@ thread = [thread_node*]
>  
>  # A message and its replies (show_messages)
>  thread_node = [
> -message?, # null if not matched and not --entire-thread
> +message|null, # null if not matched and not --entire-thread
>  [thread_node*]# children of message
>  ]
>  
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[Patch v2] Minor correction to devel/schemata

2012-06-30 Thread Mark Walters
In id:"87sjdm12d1.fsf at awakening.csail.mit.edu" Austin pointed out that
devel/schemata needs a slight correction with the new
--entire-thread=false option. This is that correction.

---

Resend with better commit message

Best wishes

Mark

 devel/schemata |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/devel/schemata b/devel/schemata
index 8fcab8e..f7e1b69 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -32,7 +32,7 @@ thread = [thread_node*]

 # A message and its replies (show_messages)
 thread_node = [
-message?, # null if not matched and not --entire-thread
+message|null, # null if not matched and not --entire-thread
 [thread_node*]# children of message
 ]

-- 
1.7.9.1



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

2012-06-30 Thread Dmitry Kurochkin
Hi Mark.

Mark Walters  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 == _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 == _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


[PATCH] Minor correction to devel/schemata

2012-06-30 Thread Mark Walters
---
In id:"87sjdm12d1.fsf at awakening.csail.mit.edu" Austin pointed out that
devel/schemata needs a slight correction with the new
--entire-thread=false option. This is that correction.

Best wishes

Mark

 devel/schemata |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/devel/schemata b/devel/schemata
index 8fcab8e..f7e1b69 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -32,7 +32,7 @@ thread = [thread_node*]

 # A message and its replies (show_messages)
 thread_node = [
-message?, # null if not matched and not --entire-thread
+message|null, # null if not matched and not --entire-thread
 [thread_node*]# children of message
 ]

-- 
1.7.9.1



[PATCH] cli: add --headers_only option to notmuch-show.c

2012-06-30 Thread Mark Walters
This option just outputs the headers of a message (i.e. it omits the
bodies). Currently this is only implemented for format=json.

This is used by notmuch-pick.el (although not needed) because it gives a
speed-up of at least a factor of a two; moreover it reduces the memory
usage in emacs hugely.
---

Currently notmuch-show outputs on a thread includes all headers and
all text/plain parts (more precisely all text/* except text/html): the
client has to fetch any other parts it wants.

This patch allows notmuch show to just output the headers: omitting
all the body parts. Jamie suggested in
id:"87zk80ilt9.fsf at servo.finestructure.net" that we always omit all
body parts and leave it to the client to fetch them. 

My feeling is that this could make some uses much slower (a view
expressed by Peter in id:"20120620110139.GA2356 at hili.localdomain").

What do people think?

Best wishes

Mark


 notmuch-client.h |3 ++-
 notmuch-reply.c  |2 +-
 notmuch-show.c   |   15 +++
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 0c17b79..17efde2 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -87,6 +87,7 @@ typedef struct notmuch_crypto {
 typedef struct notmuch_show_params {
 notmuch_bool_t entire_thread;
 notmuch_bool_t omit_excluded;
+notmuch_bool_t headers_only;
 notmuch_bool_t raw;
 int part;
 notmuch_crypto_t crypto;
@@ -176,7 +177,7 @@ notmuch_status_t
 show_one_part (const char *filename, int part);

 void
-format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first);
+format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, 
notmuch_bool_t headers_only);

 void
 format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t 
reply);
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 3a038ed..07c3bef 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -620,7 +620,7 @@ notmuch_reply_format_json(void *ctx,
 /* Start the original */
 printf (", \"original\": ");

-format_part_json (ctx, node, TRUE);
+format_part_json (ctx, node, TRUE, FALSE);

 /* End */
 printf ("}\n");
diff --git a/notmuch-show.c b/notmuch-show.c
index 8f3c60e..195e318 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -559,7 +559,7 @@ format_part_text (const void *ctx, mime_node_t *node,
 }

 void
-format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
+format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, 
notmuch_bool_t headers_only)
 {
 /* Any changes to the JSON format should be reflected in the file
  * devel/schemata. */
@@ -572,7 +572,8 @@ format_part_json (const void *ctx, mime_node_t *node, 
notmuch_bool_t first)
format_headers_json (ctx, GMIME_MESSAGE (node->part), FALSE);

printf (", \"body\": [");
-   format_part_json (ctx, mime_node_child (node, 0), first);
+   if (!headers_only)
+   format_part_json (ctx, mime_node_child (node, 0), first, FALSE);

printf ("]}");
return;
@@ -652,7 +653,7 @@ format_part_json (const void *ctx, mime_node_t *node, 
notmuch_bool_t first)
 talloc_free (local);

 for (i = 0; i < node->nchildren; i++)
-   format_part_json (ctx, mime_node_child (node, i), i == 0);
+   format_part_json (ctx, mime_node_child (node, i), i == 0, FALSE);

 printf ("%s}", terminator);
 }
@@ -661,7 +662,7 @@ static notmuch_status_t
 format_part_json_entry (const void *ctx, mime_node_t *node, unused (int 
indent),
unused (const notmuch_show_params_t *params))
 {
-format_part_json (ctx, node, TRUE);
+format_part_json (ctx, node, TRUE, params->headers_only);

 return NOTMUCH_STATUS_SUCCESS;
 }
@@ -1010,6 +1011,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
}
 };
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
+notmuch_bool_t headers_only = FALSE;
 int exclude = EXCLUDE_TRUE;
 int entire_thread = ENTIRE_THREAD_DEFAULT;

@@ -1032,6 +1034,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
{ NOTMUCH_OPT_INT, , "part", 'p', 0 },
{ NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 },
{ NOTMUCH_OPT_BOOLEAN, , "verify", 'v', 0 },
+   { NOTMUCH_OPT_BOOLEAN, _only, "headers-only", 'h', 0 },
{ 0, 0, 0, 0, 0 }
 };

@@ -1086,6 +1089,10 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
entire_thread = ENTIRE_THREAD_FALSE;
 }

+if (headers_only && format != _json)
+   fprintf (stderr,"Warning: --headers-only only implemented for 
format=json\n");
+params.headers_only = headers_only;
+
 if (entire_thread == ENTIRE_THREAD_TRUE)
params.entire_thread = TRUE;
 else
-- 
1.7.9.1



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

2012-06-30 Thread Mark Walters
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 == _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 == _json)
+   fputs ("\n", stdout);
+
notmuch_thread_destroy (thread);

 }
-- 
1.7.9.1



[PATCH] cli: add --headers_only option to notmuch-show.c

2012-06-30 Thread Mark Walters
This option just outputs the headers of a message (i.e. it omits the
bodies). Currently this is only implemented for format=json.

This is used by notmuch-pick.el (although not needed) because it gives a
speed-up of at least a factor of a two; moreover it reduces the memory
usage in emacs hugely.
---

Currently notmuch-show outputs on a thread includes all headers and
all text/plain parts (more precisely all text/* except text/html): the
client has to fetch any other parts it wants.

This patch allows notmuch show to just output the headers: omitting
all the body parts. Jamie suggested in
id:87zk80ilt9@servo.finestructure.net that we always omit all
body parts and leave it to the client to fetch them. 

My feeling is that this could make some uses much slower (a view
expressed by Peter in id:20120620110139.GA2356@hili.localdomain).

What do people think?

Best wishes

Mark


 notmuch-client.h |3 ++-
 notmuch-reply.c  |2 +-
 notmuch-show.c   |   15 +++
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 0c17b79..17efde2 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -87,6 +87,7 @@ typedef struct notmuch_crypto {
 typedef struct notmuch_show_params {
 notmuch_bool_t entire_thread;
 notmuch_bool_t omit_excluded;
+notmuch_bool_t headers_only;
 notmuch_bool_t raw;
 int part;
 notmuch_crypto_t crypto;
@@ -176,7 +177,7 @@ notmuch_status_t
 show_one_part (const char *filename, int part);
 
 void
-format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first);
+format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, 
notmuch_bool_t headers_only);
 
 void
 format_headers_json (const void *ctx, GMimeMessage *message, notmuch_bool_t 
reply);
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 3a038ed..07c3bef 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -620,7 +620,7 @@ notmuch_reply_format_json(void *ctx,
 /* Start the original */
 printf (, \original\: );
 
-format_part_json (ctx, node, TRUE);
+format_part_json (ctx, node, TRUE, FALSE);
 
 /* End */
 printf (}\n);
diff --git a/notmuch-show.c b/notmuch-show.c
index 8f3c60e..195e318 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -559,7 +559,7 @@ format_part_text (const void *ctx, mime_node_t *node,
 }
 
 void
-format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first)
+format_part_json (const void *ctx, mime_node_t *node, notmuch_bool_t first, 
notmuch_bool_t headers_only)
 {
 /* Any changes to the JSON format should be reflected in the file
  * devel/schemata. */
@@ -572,7 +572,8 @@ format_part_json (const void *ctx, mime_node_t *node, 
notmuch_bool_t first)
format_headers_json (ctx, GMIME_MESSAGE (node-part), FALSE);
 
printf (, \body\: [);
-   format_part_json (ctx, mime_node_child (node, 0), first);
+   if (!headers_only)
+   format_part_json (ctx, mime_node_child (node, 0), first, FALSE);
 
printf (]});
return;
@@ -652,7 +653,7 @@ format_part_json (const void *ctx, mime_node_t *node, 
notmuch_bool_t first)
 talloc_free (local);
 
 for (i = 0; i  node-nchildren; i++)
-   format_part_json (ctx, mime_node_child (node, i), i == 0);
+   format_part_json (ctx, mime_node_child (node, i), i == 0, FALSE);
 
 printf (%s}, terminator);
 }
@@ -661,7 +662,7 @@ static notmuch_status_t
 format_part_json_entry (const void *ctx, mime_node_t *node, unused (int 
indent),
unused (const notmuch_show_params_t *params))
 {
-format_part_json (ctx, node, TRUE);
+format_part_json (ctx, node, TRUE, params-headers_only);
 
 return NOTMUCH_STATUS_SUCCESS;
 }
@@ -1010,6 +1011,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
}
 };
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
+notmuch_bool_t headers_only = FALSE;
 int exclude = EXCLUDE_TRUE;
 int entire_thread = ENTIRE_THREAD_DEFAULT;
 
@@ -1032,6 +1034,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
{ NOTMUCH_OPT_INT, params.part, part, 'p', 0 },
{ NOTMUCH_OPT_BOOLEAN, params.crypto.decrypt, decrypt, 'd', 0 },
{ NOTMUCH_OPT_BOOLEAN, params.crypto.verify, verify, 'v', 0 },
+   { NOTMUCH_OPT_BOOLEAN, headers_only, headers-only, 'h', 0 },
{ 0, 0, 0, 0, 0 }
 };
 
@@ -1086,6 +1089,10 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
entire_thread = ENTIRE_THREAD_FALSE;
 }
 
+if (headers_only  format != format_json)
+   fprintf (stderr,Warning: --headers-only only implemented for 
format=json\n);
+params.headers_only = headers_only;
+
 if (entire_thread == ENTIRE_THREAD_TRUE)
params.entire_thread = TRUE;
 else
-- 
1.7.9.1

___
notmuch mailing list
notmuch@notmuchmail.org

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

2012-06-30 Thread Dmitry Kurochkin
Hi Mark.

Mark Walters markwalters1...@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@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Minor correction to devel/schemata

2012-06-30 Thread Mark Walters
---
In id:87sjdm12d1@awakening.csail.mit.edu Austin pointed out that
devel/schemata needs a slight correction with the new
--entire-thread=false option. This is that correction.

Best wishes

Mark

 devel/schemata |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/devel/schemata b/devel/schemata
index 8fcab8e..f7e1b69 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -32,7 +32,7 @@ thread = [thread_node*]
 
 # A message and its replies (show_messages)
 thread_node = [
-message?, # null if not matched and not --entire-thread
+message|null, # null if not matched and not --entire-thread
 [thread_node*]# children of message
 ]
 
-- 
1.7.9.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[Patch v2] Minor correction to devel/schemata

2012-06-30 Thread Mark Walters
In id:87sjdm12d1@awakening.csail.mit.edu Austin pointed out that
devel/schemata needs a slight correction with the new
--entire-thread=false option. This is that correction.

---

Resend with better commit message

Best wishes

Mark

 devel/schemata |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/devel/schemata b/devel/schemata
index 8fcab8e..f7e1b69 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -32,7 +32,7 @@ thread = [thread_node*]
 
 # A message and its replies (show_messages)
 thread_node = [
-message?, # null if not matched and not --entire-thread
+message|null, # null if not matched and not --entire-thread
 [thread_node*]# children of message
 ]
 
-- 
1.7.9.1

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [Patch v2] Minor correction to devel/schemata

2012-06-30 Thread Austin Clements
LGTM.

On Sat, 30 Jun 2012, Mark Walters markwalters1...@gmail.com wrote:
 In id:87sjdm12d1@awakening.csail.mit.edu Austin pointed out that
 devel/schemata needs a slight correction with the new
 --entire-thread=false option. This is that correction.

 ---

 Resend with better commit message

 Best wishes

 Mark

  devel/schemata |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/devel/schemata b/devel/schemata
 index 8fcab8e..f7e1b69 100644
 --- a/devel/schemata
 +++ b/devel/schemata
 @@ -32,7 +32,7 @@ thread = [thread_node*]
  
  # A message and its replies (show_messages)
  thread_node = [
 -message?, # null if not matched and not --entire-thread
 +message|null, # null if not matched and not --entire-thread
  [thread_node*]# children of message
  ]
  
 -- 
 1.7.9.1

 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch