From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [RFC PATCH v5 07/11] cli: Make notmuch-show respect excludes.
Date: Wed, 15 Feb 2012 09:03:35 +0000 [thread overview]
Message-ID: <1329296619-7463-8-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1329296619-7463-1-git-send-email-markwalters1009@gmail.com>
This adds the excludes to notmuch-show.c. We do not exclude when only
a single message (or part) is requested. notmuch-show will output the
exclude information when either text or json format is requested. As
this changes the output from notmuch-show it breaks many tests (in a
trivial and expected fashion).
---
notmuch-show.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/notmuch-show.c b/notmuch-show.c
index d930f94..2a634e9 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -179,9 +179,10 @@ format_message_json (const void *ctx, notmuch_message_t *message, unused (int in
date = notmuch_message_get_date (message);
relative_date = notmuch_time_relative_date (ctx, date);
- printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
+ printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
json_quote_str (ctx_quote, notmuch_message_get_message_id (message)),
notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false",
+ notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? "true" : "false",
json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
date, relative_date);
@@ -735,11 +736,12 @@ format_part_text (const void *ctx, mime_node_t *node,
notmuch_message_t *message = node->envelope_file;
part_type = "message";
- printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n",
+ printf ("\f%s{ id:%s depth:%d match:%d excluded:%d filename:%s\n",
part_type,
notmuch_message_get_message_id (message),
indent,
- notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
+ notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 : 0,
+ notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0,
notmuch_message_get_filename (message));
} else {
GMimeContentDisposition *disposition = g_mime_object_get_content_disposition (meta);
@@ -1034,6 +1036,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
notmuch_show_params_t params = { .part = -1 };
int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
notmuch_bool_t verify = FALSE;
+ notmuch_bool_t no_exclude = FALSE;
notmuch_opt_desc_t options[] = {
{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
@@ -1046,6 +1049,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
{ NOTMUCH_OPT_BOOLEAN, ¶ms.entire_thread, "entire-thread", 't', 0 },
{ NOTMUCH_OPT_BOOLEAN, ¶ms.decrypt, "decrypt", 'd', 0 },
{ NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },
+ { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 },
{ 0, 0, 0, 0, 0 }
};
@@ -1133,10 +1137,23 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
return 1;
}
+ /* If a single message is requested we do not use search_excludes. */
if (params.part >= 0)
ret = do_show_single (ctx, query, format, ¶ms);
- else
+ else {
+ if (!no_exclude) {
+ const char **search_exclude_tags;
+ size_t search_exclude_tags_length;
+ unsigned int i;
+
+ 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]);
+ }
ret = do_show (ctx, query, format, ¶ms);
+ }
+
notmuch_query_destroy (query);
notmuch_database_close (notmuch);
--
1.7.2.3
next prev parent reply other threads:[~2012-02-15 9:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-15 9:03 [RFC PATCH v5 00/11] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Mark Walters
2012-02-15 9:03 ` [RFC PATCH v5 01/11] cli: add --no-exclude option to count and search Mark Walters
2012-02-24 23:03 ` Austin Clements
2012-02-15 9:03 ` [RFC PATCH v5 02/11] cli: Add --no-exclude to the man pages for search and count Mark Walters
2012-02-24 23:05 ` Austin Clements
2012-02-15 9:03 ` [RFC PATCH v5 03/11] test: add tests for new cli --no-exclude option Mark Walters
2012-02-15 9:03 ` [RFC PATCH v5 04/11] lib: Rearrange the exclude code in query.cc Mark Walters
2012-02-15 9:03 ` [RFC PATCH v5 05/11] lib: Make notmuch_query_search_messages set the exclude flag Mark Walters
2012-02-24 23:39 ` Austin Clements
2012-02-15 9:03 ` [RFC PATCH v5 06/11] lib: Add the exclude flag to notmuch_query_search_threads Mark Walters
2012-02-15 9:03 ` Mark Walters [this message]
2012-02-15 9:03 ` [RFC PATCH v5 08/11] man: update manpage for notmuch-show --no-exclude option Mark Walters
2012-02-24 23:44 ` Austin Clements
2012-02-15 9:03 ` [RFC PATCH v5 09/11] test: update tests to reflect the exclude flag Mark Walters
2012-02-24 23:47 ` Austin Clements
2012-02-15 9:03 ` [RFC PATCH v5 10/11] cli: omit excluded messages in results where appropriate Mark Walters
2012-02-15 9:03 ` [RFC PATCH v5 11/11] emacs: show: recognize the exclude flag Mark Walters
2012-02-15 17:46 ` [RFC PATCH v5 00/11] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Jameson Graef Rollins
2012-02-15 18:10 ` Jameson Graef Rollins
2012-02-15 21:11 ` Mark Walters
2012-02-15 22:16 ` Jameson Graef Rollins
2012-02-15 23:59 ` Austin Clements
2012-02-16 0:30 ` Mark Walters
2012-02-24 23:58 ` Austin Clements
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=1329296619-7463-8-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).