]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-search.c
emacs: Define several faces for the crypto-status button
[notmuch] / notmuch-search.c
index a91b23110d240b755064bec12f0b2d28cd8affe0..69af6171b3461f9528460676c308749dad0e1ca3 100644 (file)
@@ -48,6 +48,7 @@ typedef struct search_format {
     const char *item_sep;
     const char *item_end;
     const char *results_end;
+    const char *results_null;
 } search_format_t;
 
 static void
@@ -73,6 +74,7 @@ static const search_format_t format_text = {
            ")", "\n",
        "",
     "\n",
+    "",
 };
 
 static void
@@ -98,6 +100,7 @@ static const search_format_t format_json = {
            "]", ",\n",
        "}",
     "]\n",
+    "]\n",
 };
 
 static void
@@ -182,15 +185,15 @@ do_search_threads (const search_format_t *format,
     if (threads == NULL)
        return 1;
 
+    fputs (format->results_start, stdout);
+
     for (;
         notmuch_threads_valid (threads);
         notmuch_threads_move_to_next (threads))
     {
        int first_tag = 1;
 
-       if (first_thread)
-           fputs (format->results_start, stdout);
-       else
+       if (! first_thread)
            fputs (format->item_sep, stdout);
 
        thread = notmuch_threads_get (threads);
@@ -236,7 +239,9 @@ do_search_threads (const search_format_t *format,
        notmuch_thread_destroy (thread);
     }
 
-    if (! first_thread)
+    if (first_thread)
+       fputs (format->results_null, stdout);
+    else
        fputs (format->results_end, stdout);
 
     return 0;
@@ -255,15 +260,15 @@ do_search_messages (const search_format_t *format,
     if (messages == NULL)
        return 1;
 
+    fputs (format->results_start, stdout);
+
     for (;
         notmuch_messages_valid (messages);
         notmuch_messages_move_to_next (messages))
     {
        message = notmuch_messages_get (messages);
 
-       if (first_message)
-           fputs (format->results_start, stdout);
-       else
+       if (! first_message)
            fputs (format->item_sep, stdout);
 
        if (output == OUTPUT_FILES) {
@@ -281,7 +286,9 @@ do_search_messages (const search_format_t *format,
 
     notmuch_messages_destroy (messages);
 
-    if (! first_message)
+    if (first_message)
+       fputs (format->results_null, stdout);
+    else
        fputs (format->results_end, stdout);
 
     return 0;
@@ -310,15 +317,15 @@ do_search_tags (notmuch_database_t *notmuch,
     if (tags == NULL)
        return 1;
 
+    fputs (format->results_start, stdout);
+
     for (;
         notmuch_tags_valid (tags);
         notmuch_tags_move_to_next (tags))
     {
        tag = notmuch_tags_get (tags);
 
-       if (first_tag)
-           fputs (format->results_start, stdout);
-       else
+       if (! first_tag)
            fputs (format->item_sep, stdout);
 
        format->item_id (tags, "", tag);
@@ -331,7 +338,9 @@ do_search_tags (notmuch_database_t *notmuch,
     if (messages)
        notmuch_messages_destroy (messages);
 
-    if (! first_tag)
+    if (first_tag)
+       fputs (format->results_null, stdout);
+    else
        fputs (format->results_end, stdout);
 
     return 0;