[PATCH 6/7] cli: omit excluded messages in results where appropriate.
Mark Walters
markwalters1009 at gmail.com
Sun Jan 29 10:39:53 PST 2012
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
--do-not-exclude option.
The relevant cases are
count: both threads and messages
search: all cases except the summary view
show: mbox format
---
notmuch-count.c | 2 ++
notmuch-search.c | 9 +++++++++
notmuch-show.c | 5 +++++
3 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/notmuch-count.c b/notmuch-count.c
index c88975e..1aa3f1a 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -87,6 +87,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));
diff --git a/notmuch-search.c b/notmuch-search.c
index 084dd05..339ce82 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -207,6 +207,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)
@@ -297,6 +300,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)
@@ -368,6 +373,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);
diff --git a/notmuch-show.c b/notmuch-show.c
index 681827f..5d98724 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1167,6 +1167,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 (mbox)
+ notmuch_query_set_omit_excluded_messages (query, TRUE);
+
/* if part was requested and format was not specified, use format=raw */
if (params.part >= 0 && !format_specified)
format = &format_raw;
--
1.7.2.3
More information about the notmuch
mailing list