]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-count.c
lib: Make notmuch_query_search_messages set the exclude flag
[notmuch] / notmuch-count.c
index 0982f99f3d9ffb2e8e6801bb43208175cb52d5a0..53645070080bba3e93356cf277fd926673e658f9 100644 (file)
@@ -35,12 +35,15 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
     char *query_str;
     int opt_index;
     int output = OUTPUT_MESSAGES;
+    notmuch_bool_t no_exclude = FALSE;
+    unsigned int i;
 
     notmuch_opt_desc_t options[] = {
        { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',
          (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
                                  { "messages", OUTPUT_MESSAGES },
                                  { 0, 0 } } },
+       { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
        { 0, 0, 0, 0, 0 }
     };
 
@@ -75,6 +78,16 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
        return 1;
     }
 
+    if (!no_exclude) {
+       const char **search_exclude_tags;
+       size_t search_exclude_tags_length;
+
+       search_exclude_tags = notmuch_config_get_search_exclude_tags
+           (config, &search_exclude_tags_length);
+       for (i = 0; i < search_exclude_tags_length; i++)
+           notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
+    }
+
     switch (output) {
     case OUTPUT_MESSAGES:
        printf ("%u\n", notmuch_query_count_messages (query));