]> git.notmuchmail.org Git - notmuch/commitdiff
cli: omit excluded messages in results where appropriate.
authorMark Walters <markwalters1009@gmail.com>
Thu, 1 Mar 2012 22:30:43 +0000 (22:30 +0000)
committerDavid Bremner <bremner@debian.org>
Fri, 2 Mar 2012 12:37:32 +0000 (08:37 -0400)
In all cases of notmuch count/search/show where the results returned
cannot reflect the exclude flag return just the matched not-excluded
results. If the caller wishes to have all the matched results (i.e.,
including the excluded ones) they should call with the
--no-exclude option.

The relevant cases are
    count: both threads and messages
    search: all cases except the summary view
    show: mbox format

notmuch-count.c
notmuch-search.c
notmuch-show.c

index 53645070080bba3e93356cf277fd926673e658f9..46b76ae1d13b9340da505ff2b8471112f50d6c87 100644 (file)
@@ -88,6 +88,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
            notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
     }
 
+    notmuch_query_set_omit_excluded_messages (query, TRUE);
+
     switch (output) {
     case OUTPUT_MESSAGES:
        printf ("%u\n", notmuch_query_count_messages (query));
index 6d6c0e609490e842910b78a481a8f39a3c5c47d7..f6061e4ec08920273450bfba954473812110504f 100644 (file)
@@ -210,6 +210,9 @@ do_search_threads (const search_format_t *format,
     int first_thread = 1;
     int i;
 
+    if (output == OUTPUT_THREADS)
+       notmuch_query_set_omit_excluded_messages (query, TRUE);
+
     if (offset < 0) {
        offset += notmuch_query_count_threads (query);
        if (offset < 0)
@@ -300,6 +303,8 @@ do_search_messages (const search_format_t *format,
     int first_message = 1;
     int i;
 
+    notmuch_query_set_omit_excluded_messages (query, TRUE);
+
     if (offset < 0) {
        offset += notmuch_query_count_messages (query);
        if (offset < 0)
@@ -371,6 +376,10 @@ do_search_tags (notmuch_database_t *notmuch,
     const char *tag;
     int first_tag = 1;
 
+    notmuch_query_set_omit_excluded_messages (query, TRUE);
+    /* should the following only special case if no excluded terms
+     * specified? */
+
     /* Special-case query of "*" for better performance. */
     if (strcmp (notmuch_query_get_query_string (query), "*") == 0) {
        tags = notmuch_database_get_all_tags (notmuch);
index 8c0b925e7ecbd922bada42cd079a2da988eec976..05d51b2716d9abc96815d317253a73abd6e410e1 100644 (file)
@@ -1030,6 +1030,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
            fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");
            return 1;
        }
+
        format = &format_mbox;
        break;
     case NOTMUCH_FORMAT_RAW:
@@ -1087,6 +1088,11 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
        return 1;
     }
 
+    /* if format=mbox then we can not output excluded messages as
+     * there is no way to make the exclude flag available */
+    if (format_sel == NOTMUCH_FORMAT_MBOX)
+       notmuch_query_set_omit_excluded_messages (query, TRUE);
+
     /* If a single message is requested we do not use search_excludes. */
     if (params.part >= 0)
        ret = do_show_single (ctx, query, format, &params);