From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/5] cli: move count to the new --exclude=(true|false|flag) naming scheme.
Date: Thu, 15 Mar 2012 18:42:02 +0000 [thread overview]
Message-ID: <1331836925-31437-3-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1331836925-31437-1-git-send-email-markwalters1009@gmail.com>
Move the option --no-exclude to the --exclude= scheme. Since there is
no way to flag messages only true and false are implemented. Note
that, for consistency with other commands, this is implemented as a
keyword option rather than a boolean option.
---
man/man1/notmuch-count.1 | 5 +++--
notmuch-count.c | 17 ++++++++++++-----
test/count | 4 ++--
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1
index 805a8ae..b169f93 100644
--- a/man/man1/notmuch-count.1
+++ b/man/man1/notmuch-count.1
@@ -41,9 +41,10 @@ Output the number of matching threads.
.RS 4
.TP 4
-.BR \-\-no\-exclude
+.BR \-\-exclude=(true|false)
-Do not exclude the messages matching search.exclude_tags in the config file.
+Specify whether to omit messages matching search.tag_exclude from the
+count (the default) or not.
.RE
.RE
.RE
diff --git a/notmuch-count.c b/notmuch-count.c
index 46b76ae..b76690c 100644
--- a/notmuch-count.c
+++ b/notmuch-count.c
@@ -26,6 +26,12 @@ enum {
OUTPUT_MESSAGES,
};
+/* The following is to allow future options to be added more easily */
+enum {
+ EXCLUDE_TRUE,
+ EXCLUDE_FALSE,
+};
+
int
notmuch_count_command (void *ctx, int argc, char *argv[])
{
@@ -35,7 +41,7 @@ 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;
+ int exclude = EXCLUDE_TRUE;
unsigned int i;
notmuch_opt_desc_t options[] = {
@@ -43,7 +49,10 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
(notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
{ "messages", OUTPUT_MESSAGES },
{ 0, 0 } } },
- { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
+ { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',
+ (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
+ { "false", EXCLUDE_FALSE },
+ { 0, 0 } } },
{ 0, 0, 0, 0, 0 }
};
@@ -78,7 +87,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
return 1;
}
- if (!no_exclude) {
+ if (exclude == EXCLUDE_TRUE) {
const char **search_exclude_tags;
size_t search_exclude_tags_length;
@@ -88,8 +97,6 @@ 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/test/count b/test/count
index b97fc06..fd387e5 100755
--- a/test/count
+++ b/test/count
@@ -53,9 +53,9 @@ test_expect_equal \
"1" \
"`notmuch count subject:deleted and tag:deleted`"
-test_begin_subtest "count \"deleted\" messages, with --no-exclude"
+test_begin_subtest "count \"deleted\" messages, --exclude=false"
test_expect_equal \
"3" \
- "`notmuch count --no-exclude subject:deleted`"
+ "`notmuch count --exclude=false subject:deleted`"
test_done
--
1.7.9.1
next prev parent reply other threads:[~2012-03-15 18:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 18:42 [PATCH 0/5] Move --no-exclude to --exclude=(true|false|flag) Mark Walters
2012-03-15 18:42 ` [PATCH 1/5] lib: change default for notmuch_query_set_omit_excluded Mark Walters
2012-03-15 18:42 ` Mark Walters [this message]
2012-03-15 18:42 ` [PATCH 3/5] cli: move search to the new --exclude= naming scheme Mark Walters
2012-03-17 15:50 ` Austin Clements
2012-03-17 19:49 ` Jameson Graef Rollins
2012-03-18 17:23 ` [PATCH] test: add some exclude tests Mark Walters
2012-03-18 18:08 ` Jameson Graef Rollins
2012-03-15 18:42 ` [PATCH 4/5] cli: move show to the new --exclude= option naming scheme Mark Walters
2012-03-17 16:51 ` Austin Clements
2012-03-18 17:30 ` Mark Walters
2012-03-15 18:42 ` [PATCH 5/5] emacs: make show set --exclude=flag Mark Walters
2012-03-17 16:52 ` Austin Clements
2012-03-17 6:02 ` [PATCH 0/5] Move --no-exclude to --exclude=(true|false|flag) Jameson Graef Rollins
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=1331836925-31437-3-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--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).