unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org, amdragon@MIT.EDU
Subject: [PATCH v4 10/11] cli: omit excluded messages in results where appropriate.
Date: Thu,  2 Feb 2012 17:43:38 +0000	[thread overview]
Message-ID: <1328204619-25046-10-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <874nv9rv79.fsf@qmul.ac.uk>

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  |    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 5364507..46b76ae 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -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));
diff --git a/notmuch-search.c b/notmuch-search.c
index 43ec90b..d2b2488 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 108f13b..924e7ea 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1166,6 +1166,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

  parent reply	other threads:[~2012-02-02 17:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-02 17:39 [Patch V4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Mark Walters
2012-02-02 17:43 ` [PATCH v4 01/11] cli: add --no-exclude option to count and search Mark Walters
2012-02-02 17:43 ` [PATCH v4 02/11] cli: Add --no-exclude to the man pages for search and count Mark Walters
2012-02-02 17:43 ` [PATCH v4 03/11] test: add tests for new cli --no-exclude option Mark Walters
2012-02-02 17:43 ` [PATCH v4 04/11] lib: Rearrange the exclude code in query.cc Mark Walters
2012-02-02 17:43 ` [PATCH v4 05/11] lib: Make notmuch_query_search_messages set the exclude flag Mark Walters
2012-02-02 17:43 ` [PATCH v4 06/11] lib: Add the exclude flag to notmuch_query_search_threads Mark Walters
2012-02-02 17:43 ` [PATCH v4 07/11] lib: added interface notmuch_thread_get_flag_messages Mark Walters
2012-02-02 21:55   ` Jani Nikula
2012-02-02 22:27     ` Mark Walters
2012-02-02 23:07       ` Jani Nikula
2012-02-02 23:24         ` Mark Walters
2012-02-03  8:48           ` Jani Nikula
2012-02-03  9:36             ` Mark Walters
2012-02-03  9:48               ` Jani Nikula
2012-02-02 17:43 ` [PATCH v4 08/11] cli: Make notmuch-show respect excludes Mark Walters
2012-02-02 22:08   ` Jani Nikula
2012-02-02 22:35     ` Mark Walters
2012-02-02 23:13       ` Jani Nikula
2012-02-02 23:19         ` Mark Walters
2012-02-02 17:43 ` [PATCH v4 09/11] test: update tests to reflect the exclude flag Mark Walters
2012-02-02 17:43 ` Mark Walters [this message]
2012-02-02 17:43 ` [PATCH v4 11/11] emacs: show: recognize " Mark Walters
2012-02-03  8:15   ` David Edmondson
2012-02-11 19:17 ` [Patch V4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Mark Walters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1328204619-25046-10-git-send-email-markwalters1009@gmail.com \
    --to=markwalters1009@gmail.com \
    --cc=amdragon@MIT.EDU \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).