[PATCH v7 3/3] Use the structured formatters in notmuch-search.c.

2012-07-20 Thread Tomi Ollila
On Fri, Jul 20 2012, craven at gmx.net wrote:

> From: 
>
> This patch switches from the current ad-hoc printer to the structured
> formatters in sprinter.h, sprinter-text.c and sprinter-json.c.
>
> The JSON tests are changed slightly in order to make them PASS for the
> new structured output formatter.
>
> The text tests pass without adaptation.
> ---
>  notmuch-search.c | 301 
> ---
>  test/json|  34 ---
>  2 files changed, 103 insertions(+), 232 deletions(-)
>
> diff --git a/notmuch-search.c b/notmuch-search.c
> index 3be296d..07211e8 100644
> --- a/notmuch-search.c
> +++ b/notmuch-search.c
> @@ -19,6 +19,7 @@
>   */
>  
>  #include "notmuch-client.h"
> +#include "sprinter.h"
>  
>  typedef enum {
>  OUTPUT_SUMMARY,
> @@ -28,92 +29,6 @@ typedef enum {
>  OUTPUT_TAGS
>  } output_t;
>  
> -typedef struct search_format {
> -const char *results_start;
> -const char *item_start;
> -void (*item_id) (const void *ctx,
> -  const char *item_type,
> -  const char *item_id);
> -void (*thread_summary) (const void *ctx,
> - const char *thread_id,
> - const time_t date,
> - const int matched,
> - const int total,
> - const char *authors,
> - const char *subject);
> -const char *tag_start;
> -const char *tag;
> -const char *tag_sep;
> -const char *tag_end;
> -const char *item_sep;
> -const char *item_end;
> -const char *results_end;
> -const char *results_null;
> -} search_format_t;
> -
> -static void
> -format_item_id_text (const void *ctx,
> -  const char *item_type,
> -  const char *item_id);
> -
> -static void
> -format_thread_text (const void *ctx,
> - const char *thread_id,
> - const time_t date,
> - const int matched,
> - const int total,
> - const char *authors,
> - const char *subject);
> -static const search_format_t format_text = {
> -"",
> - "",
> - format_item_id_text,
> - format_thread_text,
> - " (",
> - "%s", " ",
> - ")", "\n",
> - "",
> -"\n",
> -"",
> -};
> -
> -static void
> -format_item_id_json (const void *ctx,
> -  const char *item_type,
> -  const char *item_id);
> -
> -static void
> -format_thread_json (const void *ctx,
> - const char *thread_id,
> - const time_t date,
> - const int matched,
> - const int total,
> - const char *authors,
> - const char *subject);
> -
> -/* Any changes to the JSON format should be reflected in the file
> - * devel/schemata. */
> -static const search_format_t format_json = {
> -"[",
> - "{",
> - format_item_id_json,
> - format_thread_json,
> - "\"tags\": [",
> - "\"%s\"", ", ",
> - "]", ",\n",
> - "}",
> -"]\n",
> -"]\n",
> -};
> -
> -static void
> -format_item_id_text (unused (const void *ctx),
> -  const char *item_type,
> -  const char *item_id)
> -{
> -printf ("%s%s", item_type, item_id);
> -}
> -
>  static char *
>  sanitize_string (const void *ctx, const char *str)
>  {
> @@ -131,72 +46,8 @@ sanitize_string (const void *ctx, const char *str)
>  return out;
>  }
>  
> -static void
> -format_thread_text (const void *ctx,
> - const char *thread_id,
> - const time_t date,
> - const int matched,
> - const int total,
> - const char *authors,
> - const char *subject)
> -{
> -void *ctx_quote = talloc_new (ctx);
> -
> -printf ("thread:%s %12s [%d/%d] %s; %s",
> - thread_id,
> - notmuch_time_relative_date (ctx, date),
> - matched,
> - total,
> - sanitize_string (ctx_quote, authors),
> - sanitize_string (ctx_quote, subject));
> -
> -talloc_free (ctx_quote);
> -}
> -
> -static void
> -format_item_id_json (const void *ctx,
> -  unused (const char *item_type),
> -  const char *item_id)
> -{
> -void *ctx_quote = talloc_new (ctx);
> -
> -printf ("%s", json_quote_str (ctx_quote, item_id));
> -
> -talloc_free (ctx_quote);
> -
> -}
> -
> -static void
> -format_thread_json (const void *ctx,
> - const char *thread_id,
> - const time_t date,
> - const int matched,
> - const int total,
> - const char *authors,
> - const char *subject)
> -{
> -void *ctx_quote = talloc_new (ctx);
> -
> -printf ("\"thread\": %s,\n"
> - "\"timestamp\": %ld,\n"
> - 

[PATCH v7 3/3] Use the structured formatters in notmuch-search.c.

2012-07-20 Thread cra...@gmx.net
From: 

This patch switches from the current ad-hoc printer to the structured
formatters in sprinter.h, sprinter-text.c and sprinter-json.c.

The JSON tests are changed slightly in order to make them PASS for the
new structured output formatter.

The text tests pass without adaptation.
---
 notmuch-search.c | 301 ---
 test/json|  34 ---
 2 files changed, 103 insertions(+), 232 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 3be296d..07211e8 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -19,6 +19,7 @@
  */

 #include "notmuch-client.h"
+#include "sprinter.h"

 typedef enum {
 OUTPUT_SUMMARY,
@@ -28,92 +29,6 @@ typedef enum {
 OUTPUT_TAGS
 } output_t;

-typedef struct search_format {
-const char *results_start;
-const char *item_start;
-void (*item_id) (const void *ctx,
-const char *item_type,
-const char *item_id);
-void (*thread_summary) (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-const char *tag_start;
-const char *tag;
-const char *tag_sep;
-const char *tag_end;
-const char *item_sep;
-const char *item_end;
-const char *results_end;
-const char *results_null;
-} search_format_t;
-
-static void
-format_item_id_text (const void *ctx,
-const char *item_type,
-const char *item_id);
-
-static void
-format_thread_text (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-static const search_format_t format_text = {
-"",
-   "",
-   format_item_id_text,
-   format_thread_text,
-   " (",
-   "%s", " ",
-   ")", "\n",
-   "",
-"\n",
-"",
-};
-
-static void
-format_item_id_json (const void *ctx,
-const char *item_type,
-const char *item_id);
-
-static void
-format_thread_json (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-
-/* Any changes to the JSON format should be reflected in the file
- * devel/schemata. */
-static const search_format_t format_json = {
-"[",
-   "{",
-   format_item_id_json,
-   format_thread_json,
-   "\"tags\": [",
-   "\"%s\"", ", ",
-   "]", ",\n",
-   "}",
-"]\n",
-"]\n",
-};
-
-static void
-format_item_id_text (unused (const void *ctx),
-const char *item_type,
-const char *item_id)
-{
-printf ("%s%s", item_type, item_id);
-}
-
 static char *
 sanitize_string (const void *ctx, const char *str)
 {
@@ -131,72 +46,8 @@ sanitize_string (const void *ctx, const char *str)
 return out;
 }

-static void
-format_thread_text (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf ("thread:%s %12s [%d/%d] %s; %s",
-   thread_id,
-   notmuch_time_relative_date (ctx, date),
-   matched,
-   total,
-   sanitize_string (ctx_quote, authors),
-   sanitize_string (ctx_quote, subject));
-
-talloc_free (ctx_quote);
-}
-
-static void
-format_item_id_json (const void *ctx,
-unused (const char *item_type),
-const char *item_id)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf ("%s", json_quote_str (ctx_quote, item_id));
-
-talloc_free (ctx_quote);
-
-}
-
-static void
-format_thread_json (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf ("\"thread\": %s,\n"
-   "\"timestamp\": %ld,\n"
-   "\"date_relative\": \"%s\",\n"
-   "\"matched\": %d,\n"
-   "\"total\": %d,\n"
-   "\"authors\": %s,\n"
-   "\"subject\": %s,\n",
-   json_quote_str (ctx_quote, thread_id),
-   date,
-   

[PATCH v7 3/3] Use the structured formatters in notmuch-search.c.

2012-07-20 Thread cra...@gmx.net
From: 

This patch switches from the current ad-hoc printer to the structured
formatters in sprinter.h, sprinter-text.c and sprinter-json.c.

The JSON tests are changed slightly in order to make them PASS for the
new structured output formatter.

The text tests pass without adaptation.
---
 notmuch-search.c | 301 ---
 test/json|  34 ---
 2 files changed, 103 insertions(+), 232 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 3be296d..07211e8 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -19,6 +19,7 @@
  */

 #include "notmuch-client.h"
+#include "sprinter.h"

 typedef enum {
 OUTPUT_SUMMARY,
@@ -28,92 +29,6 @@ typedef enum {
 OUTPUT_TAGS
 } output_t;

-typedef struct search_format {
-const char *results_start;
-const char *item_start;
-void (*item_id) (const void *ctx,
-const char *item_type,
-const char *item_id);
-void (*thread_summary) (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-const char *tag_start;
-const char *tag;
-const char *tag_sep;
-const char *tag_end;
-const char *item_sep;
-const char *item_end;
-const char *results_end;
-const char *results_null;
-} search_format_t;
-
-static void
-format_item_id_text (const void *ctx,
-const char *item_type,
-const char *item_id);
-
-static void
-format_thread_text (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-static const search_format_t format_text = {
-"",
-   "",
-   format_item_id_text,
-   format_thread_text,
-   " (",
-   "%s", " ",
-   ")", "\n",
-   "",
-"\n",
-"",
-};
-
-static void
-format_item_id_json (const void *ctx,
-const char *item_type,
-const char *item_id);
-
-static void
-format_thread_json (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-
-/* Any changes to the JSON format should be reflected in the file
- * devel/schemata. */
-static const search_format_t format_json = {
-"[",
-   "{",
-   format_item_id_json,
-   format_thread_json,
-   "\"tags\": [",
-   "\"%s\"", ", ",
-   "]", ",\n",
-   "}",
-"]\n",
-"]\n",
-};
-
-static void
-format_item_id_text (unused (const void *ctx),
-const char *item_type,
-const char *item_id)
-{
-printf ("%s%s", item_type, item_id);
-}
-
 static char *
 sanitize_string (const void *ctx, const char *str)
 {
@@ -131,72 +46,8 @@ sanitize_string (const void *ctx, const char *str)
 return out;
 }

-static void
-format_thread_text (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf ("thread:%s %12s [%d/%d] %s; %s",
-   thread_id,
-   notmuch_time_relative_date (ctx, date),
-   matched,
-   total,
-   sanitize_string (ctx_quote, authors),
-   sanitize_string (ctx_quote, subject));
-
-talloc_free (ctx_quote);
-}
-
-static void
-format_item_id_json (const void *ctx,
-unused (const char *item_type),
-const char *item_id)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf ("%s", json_quote_str (ctx_quote, item_id));
-
-talloc_free (ctx_quote);
-
-}
-
-static void
-format_thread_json (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf ("\"thread\": %s,\n"
-   "\"timestamp\": %ld,\n"
-   "\"date_relative\": \"%s\",\n"
-   "\"matched\": %d,\n"
-   "\"total\": %d,\n"
-   "\"authors\": %s,\n"
-   "\"subject\": %s,\n",
-   json_quote_str (ctx_quote, thread_id),
-   date,
-   

[PATCH v7 3/3] Use the structured formatters in notmuch-search.c.

2012-07-20 Thread craven
From: cra...@gmx.net

This patch switches from the current ad-hoc printer to the structured
formatters in sprinter.h, sprinter-text.c and sprinter-json.c.

The JSON tests are changed slightly in order to make them PASS for the
new structured output formatter.

The text tests pass without adaptation.
---
 notmuch-search.c | 301 ---
 test/json|  34 ---
 2 files changed, 103 insertions(+), 232 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 3be296d..07211e8 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -19,6 +19,7 @@
  */
 
 #include notmuch-client.h
+#include sprinter.h
 
 typedef enum {
 OUTPUT_SUMMARY,
@@ -28,92 +29,6 @@ typedef enum {
 OUTPUT_TAGS
 } output_t;
 
-typedef struct search_format {
-const char *results_start;
-const char *item_start;
-void (*item_id) (const void *ctx,
-const char *item_type,
-const char *item_id);
-void (*thread_summary) (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-const char *tag_start;
-const char *tag;
-const char *tag_sep;
-const char *tag_end;
-const char *item_sep;
-const char *item_end;
-const char *results_end;
-const char *results_null;
-} search_format_t;
-
-static void
-format_item_id_text (const void *ctx,
-const char *item_type,
-const char *item_id);
-
-static void
-format_thread_text (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-static const search_format_t format_text = {
-,
-   ,
-   format_item_id_text,
-   format_thread_text,
-(,
-   %s,  ,
-   ), \n,
-   ,
-\n,
-,
-};
-
-static void
-format_item_id_json (const void *ctx,
-const char *item_type,
-const char *item_id);
-
-static void
-format_thread_json (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-
-/* Any changes to the JSON format should be reflected in the file
- * devel/schemata. */
-static const search_format_t format_json = {
-[,
-   {,
-   format_item_id_json,
-   format_thread_json,
-   \tags\: [,
-   \%s\, , ,
-   ], ,\n,
-   },
-]\n,
-]\n,
-};
-
-static void
-format_item_id_text (unused (const void *ctx),
-const char *item_type,
-const char *item_id)
-{
-printf (%s%s, item_type, item_id);
-}
-
 static char *
 sanitize_string (const void *ctx, const char *str)
 {
@@ -131,72 +46,8 @@ sanitize_string (const void *ctx, const char *str)
 return out;
 }
 
-static void
-format_thread_text (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf (thread:%s %12s [%d/%d] %s; %s,
-   thread_id,
-   notmuch_time_relative_date (ctx, date),
-   matched,
-   total,
-   sanitize_string (ctx_quote, authors),
-   sanitize_string (ctx_quote, subject));
-
-talloc_free (ctx_quote);
-}
-
-static void
-format_item_id_json (const void *ctx,
-unused (const char *item_type),
-const char *item_id)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf (%s, json_quote_str (ctx_quote, item_id));
-
-talloc_free (ctx_quote);
-
-}
-
-static void
-format_thread_json (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf (\thread\: %s,\n
-   \timestamp\: %ld,\n
-   \date_relative\: \%s\,\n
-   \matched\: %d,\n
-   \total\: %d,\n
-   \authors\: %s,\n
-   \subject\: %s,\n,
-   json_quote_str (ctx_quote, thread_id),
-   date,
-   notmuch_time_relative_date (ctx, date),
-   matched,
-   total,
-   

[PATCH v7 3/3] Use the structured formatters in notmuch-search.c.

2012-07-20 Thread craven
From: cra...@gmx.net

This patch switches from the current ad-hoc printer to the structured
formatters in sprinter.h, sprinter-text.c and sprinter-json.c.

The JSON tests are changed slightly in order to make them PASS for the
new structured output formatter.

The text tests pass without adaptation.
---
 notmuch-search.c | 301 ---
 test/json|  34 ---
 2 files changed, 103 insertions(+), 232 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 3be296d..07211e8 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -19,6 +19,7 @@
  */
 
 #include notmuch-client.h
+#include sprinter.h
 
 typedef enum {
 OUTPUT_SUMMARY,
@@ -28,92 +29,6 @@ typedef enum {
 OUTPUT_TAGS
 } output_t;
 
-typedef struct search_format {
-const char *results_start;
-const char *item_start;
-void (*item_id) (const void *ctx,
-const char *item_type,
-const char *item_id);
-void (*thread_summary) (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-const char *tag_start;
-const char *tag;
-const char *tag_sep;
-const char *tag_end;
-const char *item_sep;
-const char *item_end;
-const char *results_end;
-const char *results_null;
-} search_format_t;
-
-static void
-format_item_id_text (const void *ctx,
-const char *item_type,
-const char *item_id);
-
-static void
-format_thread_text (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-static const search_format_t format_text = {
-,
-   ,
-   format_item_id_text,
-   format_thread_text,
-(,
-   %s,  ,
-   ), \n,
-   ,
-\n,
-,
-};
-
-static void
-format_item_id_json (const void *ctx,
-const char *item_type,
-const char *item_id);
-
-static void
-format_thread_json (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject);
-
-/* Any changes to the JSON format should be reflected in the file
- * devel/schemata. */
-static const search_format_t format_json = {
-[,
-   {,
-   format_item_id_json,
-   format_thread_json,
-   \tags\: [,
-   \%s\, , ,
-   ], ,\n,
-   },
-]\n,
-]\n,
-};
-
-static void
-format_item_id_text (unused (const void *ctx),
-const char *item_type,
-const char *item_id)
-{
-printf (%s%s, item_type, item_id);
-}
-
 static char *
 sanitize_string (const void *ctx, const char *str)
 {
@@ -131,72 +46,8 @@ sanitize_string (const void *ctx, const char *str)
 return out;
 }
 
-static void
-format_thread_text (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf (thread:%s %12s [%d/%d] %s; %s,
-   thread_id,
-   notmuch_time_relative_date (ctx, date),
-   matched,
-   total,
-   sanitize_string (ctx_quote, authors),
-   sanitize_string (ctx_quote, subject));
-
-talloc_free (ctx_quote);
-}
-
-static void
-format_item_id_json (const void *ctx,
-unused (const char *item_type),
-const char *item_id)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf (%s, json_quote_str (ctx_quote, item_id));
-
-talloc_free (ctx_quote);
-
-}
-
-static void
-format_thread_json (const void *ctx,
-   const char *thread_id,
-   const time_t date,
-   const int matched,
-   const int total,
-   const char *authors,
-   const char *subject)
-{
-void *ctx_quote = talloc_new (ctx);
-
-printf (\thread\: %s,\n
-   \timestamp\: %ld,\n
-   \date_relative\: \%s\,\n
-   \matched\: %d,\n
-   \total\: %d,\n
-   \authors\: %s,\n
-   \subject\: %s,\n,
-   json_quote_str (ctx_quote, thread_id),
-   date,
-   notmuch_time_relative_date (ctx, date),
-   matched,
-   total,
-   

Re: [PATCH v7 3/3] Use the structured formatters in notmuch-search.c.

2012-07-20 Thread Tomi Ollila
On Fri, Jul 20 2012, cra...@gmx.net wrote:

 From: cra...@gmx.net

 This patch switches from the current ad-hoc printer to the structured
 formatters in sprinter.h, sprinter-text.c and sprinter-json.c.

 The JSON tests are changed slightly in order to make them PASS for the
 new structured output formatter.

 The text tests pass without adaptation.
 ---
  notmuch-search.c | 301 
 ---
  test/json|  34 ---
  2 files changed, 103 insertions(+), 232 deletions(-)

 diff --git a/notmuch-search.c b/notmuch-search.c
 index 3be296d..07211e8 100644
 --- a/notmuch-search.c
 +++ b/notmuch-search.c
 @@ -19,6 +19,7 @@
   */
  
  #include notmuch-client.h
 +#include sprinter.h
  
  typedef enum {
  OUTPUT_SUMMARY,
 @@ -28,92 +29,6 @@ typedef enum {
  OUTPUT_TAGS
  } output_t;
  
 -typedef struct search_format {
 -const char *results_start;
 -const char *item_start;
 -void (*item_id) (const void *ctx,
 -  const char *item_type,
 -  const char *item_id);
 -void (*thread_summary) (const void *ctx,
 - const char *thread_id,
 - const time_t date,
 - const int matched,
 - const int total,
 - const char *authors,
 - const char *subject);
 -const char *tag_start;
 -const char *tag;
 -const char *tag_sep;
 -const char *tag_end;
 -const char *item_sep;
 -const char *item_end;
 -const char *results_end;
 -const char *results_null;
 -} search_format_t;
 -
 -static void
 -format_item_id_text (const void *ctx,
 -  const char *item_type,
 -  const char *item_id);
 -
 -static void
 -format_thread_text (const void *ctx,
 - const char *thread_id,
 - const time_t date,
 - const int matched,
 - const int total,
 - const char *authors,
 - const char *subject);
 -static const search_format_t format_text = {
 -,
 - ,
 - format_item_id_text,
 - format_thread_text,
 -  (,
 - %s,  ,
 - ), \n,
 - ,
 -\n,
 -,
 -};
 -
 -static void
 -format_item_id_json (const void *ctx,
 -  const char *item_type,
 -  const char *item_id);
 -
 -static void
 -format_thread_json (const void *ctx,
 - const char *thread_id,
 - const time_t date,
 - const int matched,
 - const int total,
 - const char *authors,
 - const char *subject);
 -
 -/* Any changes to the JSON format should be reflected in the file
 - * devel/schemata. */
 -static const search_format_t format_json = {
 -[,
 - {,
 - format_item_id_json,
 - format_thread_json,
 - \tags\: [,
 - \%s\, , ,
 - ], ,\n,
 - },
 -]\n,
 -]\n,
 -};
 -
 -static void
 -format_item_id_text (unused (const void *ctx),
 -  const char *item_type,
 -  const char *item_id)
 -{
 -printf (%s%s, item_type, item_id);
 -}
 -
  static char *
  sanitize_string (const void *ctx, const char *str)
  {
 @@ -131,72 +46,8 @@ sanitize_string (const void *ctx, const char *str)
  return out;
  }
  
 -static void
 -format_thread_text (const void *ctx,
 - const char *thread_id,
 - const time_t date,
 - const int matched,
 - const int total,
 - const char *authors,
 - const char *subject)
 -{
 -void *ctx_quote = talloc_new (ctx);
 -
 -printf (thread:%s %12s [%d/%d] %s; %s,
 - thread_id,
 - notmuch_time_relative_date (ctx, date),
 - matched,
 - total,
 - sanitize_string (ctx_quote, authors),
 - sanitize_string (ctx_quote, subject));
 -
 -talloc_free (ctx_quote);
 -}
 -
 -static void
 -format_item_id_json (const void *ctx,
 -  unused (const char *item_type),
 -  const char *item_id)
 -{
 -void *ctx_quote = talloc_new (ctx);
 -
 -printf (%s, json_quote_str (ctx_quote, item_id));
 -
 -talloc_free (ctx_quote);
 -
 -}
 -
 -static void
 -format_thread_json (const void *ctx,
 - const char *thread_id,
 - const time_t date,
 - const int matched,
 - const int total,
 - const char *authors,
 - const char *subject)
 -{
 -void *ctx_quote = talloc_new (ctx);
 -
 -printf (\thread\: %s,\n
 - \timestamp\: %ld,\n
 - \date_relative\: \%s\,\n
 - \matched\: %d,\n
 - \total\: %d,\n
 - \authors\: %s,\n
 - \subject\: %s,\n,
 - json_quote_str (ctx_quote, thread_id),
 - date,
 -