[PATCH 8/8] cli: use notmuch_exclude_t in option parser
Use notmuch_exclude_t constants directly instead of a redundant enumeration while parsing search --exclude keyword arguments. --- notmuch-search.c | 28 +--- 1 files changed, 9 insertions(+), 19 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 027923d..23cf342 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -416,13 +416,6 @@ do_search_tags (notmuch_database_t *notmuch, return 0; } -enum { -EXCLUDE_TRUE, -EXCLUDE_FALSE, -EXCLUDE_FLAG, -EXCLUDE_ALL -}; - int notmuch_search_command (void *ctx, int argc, char *argv[]) { @@ -436,7 +429,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) output_t output = OUTPUT_SUMMARY; int offset = 0; int limit = -1; /* unlimited */ -int exclude = EXCLUDE_TRUE; +notmuch_exclude_t exclude = NOTMUCH_EXCLUDE_TRUE; unsigned int i; enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT } @@ -459,10 +452,10 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) { "tags", OUTPUT_TAGS }, { 0, 0 } } }, { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x', - (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, - { "false", EXCLUDE_FALSE }, - { "flag", EXCLUDE_FLAG }, - { "all", EXCLUDE_ALL }, + (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, + { "false", NOTMUCH_EXCLUDE_FALSE }, + { "flag", NOTMUCH_EXCLUDE_FLAG }, + { "all", NOTMUCH_EXCLUDE_ALL }, { 0, 0 } } }, { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, @@ -510,15 +503,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) notmuch_query_set_sort (query, sort); -if (exclude == EXCLUDE_FLAG && output != OUTPUT_SUMMARY) { +if (exclude == NOTMUCH_EXCLUDE_FLAG && output != OUTPUT_SUMMARY) { /* If we are not doing summary output there is nowhere to * print the excluded flag so fall back on including the * excluded messages. */ fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n"); - exclude = EXCLUDE_FALSE; + exclude = NOTMUCH_EXCLUDE_FALSE; } -if (exclude != EXCLUDE_FALSE) { +if (exclude != NOTMUCH_EXCLUDE_FALSE) { const char **search_exclude_tags; size_t search_exclude_tags_length; @@ -526,10 +519,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) (config, &search_exclude_tags_length); for (i = 0; i < search_exclude_tags_length; i++) notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); - if (exclude == EXCLUDE_FLAG) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FLAG); - if (exclude == EXCLUDE_ALL) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); + notmuch_query_set_omit_excluded (query, exclude); } switch (output) { -- 1.7.4.4
[PATCH 7/8] lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t
Add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t so that it can cover all four values of search --exclude in the cli. --- lib/notmuch.h|1 + lib/query.cc |6 -- notmuch-search.c |2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/notmuch.h b/lib/notmuch.h index 1280afd..f4381ae 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -504,6 +504,7 @@ notmuch_query_get_query_string (notmuch_query_t *query); typedef enum { NOTMUCH_EXCLUDE_FALSE, NOTMUCH_EXCLUDE_TRUE, +NOTMUCH_EXCLUDE_FLAG, NOTMUCH_EXCLUDE_ALL } notmuch_exclude_t; diff --git a/lib/query.cc b/lib/query.cc index f752452..1e0f292 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -221,10 +221,12 @@ notmuch_query_search_messages (notmuch_query_t *query) if (query->exclude_terms) { exclude_query = _notmuch_exclude_tags (query, final_query); - if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) + if (query->omit_excluded == NOTMUCH_EXCLUDE_TRUE || + query->omit_excluded == NOTMUCH_EXCLUDE_ALL) + { final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, final_query, exclude_query); - else { + } else { exclude_query = Xapian::Query (Xapian::Query::OP_AND, exclude_query, final_query); diff --git a/notmuch-search.c b/notmuch-search.c index 89b5bf9..027923d 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -527,7 +527,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) for (i = 0; i < search_exclude_tags_length; i++) notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); if (exclude == EXCLUDE_FLAG) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE); + notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FLAG); if (exclude == EXCLUDE_ALL) notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); } -- 1.7.4.4
[PATCH 6/8] man: document search --exclude=all
Document the new search --exclude=all option. --- man/man1/notmuch-search.1 |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 index e23ca30..1d8d57a 100644 --- a/man/man1/notmuch-search.1 +++ b/man/man1/notmuch-search.1 @@ -114,7 +114,7 @@ Limit the number of displayed results to N. .RS 4 .TP 4 -.BR \-\-exclude=(true|false|flag) +.BR \-\-exclude=(true|false|all|flag) Messages matching search.tag_exclude are called "excluded messages". This option specifies whether to omit excluded messages in the search @@ -124,6 +124,10 @@ The default value, .BR true , prevents excluded messages from matching the search terms. +.B all +additionally prevents excluded messages from appearing in displayed +results, in effect behaving as though the excluded messages do not exist. + .B false allows excluded messages to match search terms and appear in displayed results. Excluded messages are still marked in the relevant outputs. -- 1.7.4.4
[PATCH 5/8] man: clarify search --exclude=flag
Improve the description of the search --exclude=flag option, using text taken from the commit that introduced the option. --- man/man1/notmuch-search.1 |8 +--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 index 003b742..e23ca30 100644 --- a/man/man1/notmuch-search.1 +++ b/man/man1/notmuch-search.1 @@ -130,9 +130,11 @@ results. Excluded messages are still marked in the relevant outputs. .B flag only has an effect when -.B --output=summary -In this case all matching threads are returned but the "match count" -is the number of matching non-excluded messages in the thread. +.BR --output=summary . +The output is almost identical to +.BR false , +but the "match count" is the number of matching non-excluded messages in the +thread, rather than the number of matching messages. .RE .SH SEE ALSO -- 1.7.4.4
[PATCH 4/8] man: clarify search --exclude documentation
Highlight "excluded messages" as a piece of jargon with a meaning that may not be obvious. Be explicit about the effects of search --exclude=true and --exclude=false. --- man/man1/notmuch-search.1 | 14 -- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 index 5c72c4b..003b742 100644 --- a/man/man1/notmuch-search.1 +++ b/man/man1/notmuch-search.1 @@ -116,8 +116,18 @@ Limit the number of displayed results to N. .TP 4 .BR \-\-exclude=(true|false|flag) -Specify whether to omit messages matching search.tag_exclude from the -search results (the default) or not. The extra option +Messages matching search.tag_exclude are called "excluded messages". +This option specifies whether to omit excluded messages in the search +process. + +The default value, +.BR true , +prevents excluded messages from matching the search terms. + +.B false +allows excluded messages to match search terms and appear in displayed +results. Excluded messages are still marked in the relevant outputs. + .B flag only has an effect when .B --output=summary -- 1.7.4.4
[PATCH 3/8] test: add tests for search --exclude=all
Test the new search --exclude=all option. --- test/excludes | 22 ++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/test/excludes b/test/excludes index 24d653e..f1ae9ea 100755 --- a/test/excludes +++ b/test/excludes @@ -166,6 +166,16 @@ ${matching_message_ids[3]} ${matching_message_ids[4]} ${matching_message_ids[5]}" +test_begin_subtest "Search, exclude=all (thread summary)" +output=$(notmuch search --exclude=all tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: reply 4 (inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; No messages excluded: single match: reply 3 (inbox test unread)" + +test_begin_subtest "Search, exclude=all (messages)" +output=$(notmuch search --exclude=all --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[4]} +${matching_message_ids[5]}" + test_begin_subtest "Search, default exclusion: tag in query (thread summary)" output=$(notmuch search tag:test and tag:deleted | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) @@ -218,6 +228,18 @@ ${matching_message_ids[1]} ${matching_message_ids[2]} ${matching_message_ids[3]}" +test_begin_subtest "Search, exclude=all: tag in query (thread summary)" +output=$(notmuch search --exclude=all tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/6] Notmuch Test Suite; All messages excluded: double match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single excluded match: reply 3 (deleted inbox test unread)" + +test_begin_subtest "Search, exclude=all: tag in query (messages)" +output=$(notmuch search --exclude=all --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[0]} +${matching_message_ids[1]} +${matching_message_ids[2]} +${matching_message_ids[3]}" # # Notmuch count tests -- 1.7.4.4
[PATCH 2/8] cli: add --exclude=all option to notmuch-search.c
From: Mark Walters Add a --exclude=all option to notmuch search. --- notmuch-search.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 3be296d..89b5bf9 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -420,6 +420,7 @@ enum { EXCLUDE_TRUE, EXCLUDE_FALSE, EXCLUDE_FLAG, +EXCLUDE_ALL }; int @@ -461,6 +462,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, { "false", EXCLUDE_FALSE }, { "flag", EXCLUDE_FLAG }, + { "all", EXCLUDE_ALL }, { 0, 0 } } }, { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, @@ -516,7 +518,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) exclude = EXCLUDE_FALSE; } -if (exclude == EXCLUDE_TRUE || exclude == EXCLUDE_FLAG) { +if (exclude != EXCLUDE_FALSE) { const char **search_exclude_tags; size_t search_exclude_tags_length; @@ -525,7 +527,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) for (i = 0; i < search_exclude_tags_length; i++) notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); if (exclude == EXCLUDE_FLAG) - notmuch_query_set_omit_excluded (query, FALSE); + notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE); + if (exclude == EXCLUDE_ALL) + notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); } switch (output) { -- 1.7.4.4
[PATCH 1/8] lib: add --exclude=all option
From: Mark Walters Adds a exclude all option to the lib which means that excluded messages are completely ignored (as if they had actually been deleted). --- lib/notmuch-private.h |1 + lib/notmuch.h | 22 +++--- lib/query.cc | 10 ++ lib/thread.cc | 41 ++--- 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index bfb4111..aa799b4 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -232,6 +232,7 @@ _notmuch_thread_create (void *ctx, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, notmuch_string_list_t *excluded_terms, + notmuch_exclude_t omit_exclude, notmuch_sort_t sort); /* message.cc */ diff --git a/lib/notmuch.h b/lib/notmuch.h index 3633bed..1280afd 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -500,14 +500,22 @@ typedef enum { const char * notmuch_query_get_query_string (notmuch_query_t *query); +/* Exclude values for notmuch_query_set_omit_excluded */ +typedef enum { +NOTMUCH_EXCLUDE_FALSE, +NOTMUCH_EXCLUDE_TRUE, +NOTMUCH_EXCLUDE_ALL +} notmuch_exclude_t; + /* Specify whether to omit excluded results or simply flag them. By * default, this is set to TRUE. * - * If this is TRUE, notmuch_query_search_messages will omit excluded - * messages from the results. notmuch_query_search_threads will omit - * threads that match only in excluded messages, but will include all - * messages in threads that match in at least one non-excluded - * message. + * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded + * messages from the results, and notmuch_query_search_threads will omit + * threads that match only in excluded messages. If set to TRUE, + * notmuch_query_search_threads will include all messages in threads that + * match in at least one non-excluded message. Otherwise, if set to ALL, + * notmuch_query_search_threads will omit excluded messages from all threads. * * The performance difference when calling * notmuch_query_search_messages should be relatively small (and both @@ -516,9 +524,9 @@ notmuch_query_get_query_string (notmuch_query_t *query); * excluded messages as it does not need to construct the threads that * only match in excluded messages. */ - void -notmuch_query_set_omit_excluded (notmuch_query_t *query, notmuch_bool_t omit_excluded); +notmuch_query_set_omit_excluded (notmuch_query_t *query, +notmuch_exclude_t omit_excluded); /* Specify the sorting desired for this query. */ void diff --git a/lib/query.cc b/lib/query.cc index e9c1a2d..f752452 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -28,7 +28,7 @@ struct _notmuch_query { const char *query_string; notmuch_sort_t sort; notmuch_string_list_t *exclude_terms; -notmuch_bool_t omit_excluded; +notmuch_exclude_t omit_excluded; }; typedef struct _notmuch_mset_messages { @@ -92,7 +92,7 @@ notmuch_query_create (notmuch_database_t *notmuch, query->exclude_terms = _notmuch_string_list_create (query); -query->omit_excluded = TRUE; +query->omit_excluded = NOTMUCH_EXCLUDE_TRUE; return query; } @@ -104,7 +104,8 @@ notmuch_query_get_query_string (notmuch_query_t *query) } void -notmuch_query_set_omit_excluded (notmuch_query_t *query, notmuch_bool_t omit_excluded) +notmuch_query_set_omit_excluded (notmuch_query_t *query, +notmuch_exclude_t omit_excluded) { query->omit_excluded = omit_excluded; } @@ -220,7 +221,7 @@ notmuch_query_search_messages (notmuch_query_t *query) if (query->exclude_terms) { exclude_query = _notmuch_exclude_tags (query, final_query); - if (query->omit_excluded) + if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, final_query, exclude_query); else { @@ -486,6 +487,7 @@ notmuch_threads_get (notmuch_threads_t *threads) doc_id, &threads->match_set, threads->query->exclude_terms, + threads->query->omit_excluded, threads->query->sort); } diff --git a/lib/thread.cc b/lib/thread.cc index e976d64..4cb0896 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -215,7 +215,8 @@ _thread_cleanup_author (notmuch_thread_t *thread, static void _thread_add_message (notmuch_thread_t *thread, notmuch_message_t *message, -notmuch_string_list_t *exclude_terms) +notmuch_string_list_t *exclude_terms, +notmuch_exclude_t omit_exclude) { notmuch_tags_t *t
[PATCH 0/8] search --exclude=all
Hi, This is Mark's change to add search --exclude=all. I mainly just updated a comment and added some documentation. Mark Walters (2): lib: add --exclude=all option cli: add --exclude=all option to notmuch-search.c Peter Wang (6): test: add tests for search --exclude=all man: clarify search --exclude documentation man: clarify search --exclude=flag man: document search --exclude=all lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t cli: use notmuch_exclude_t in option parser lib/notmuch-private.h |1 + lib/notmuch.h | 23 --- lib/query.cc | 14 +- lib/thread.cc | 41 ++--- man/man1/notmuch-search.1 | 28 ++-- notmuch-search.c | 24 +--- test/excludes | 22 ++ 7 files changed, 109 insertions(+), 44 deletions(-) -- 1.7.4.4
miraculous from: field
On Wed, Jun 20, 2012 at 5:33 AM, Jani Nikula wrote: > The reply template comes from 'notmuch reply' cli command, while the > forwarding is internal to the emacs ui. I don't have any quick solutions, > but perhaps in the long run we should do the forwarding template in the cli > too. I think this is the right approach. Someone suggested a while ago that we have a notmuch compose, which would do new message creation (for frontends that can't do it themselves), reply, and forward in one place. It would probably support raw and JSON like the current reply does. Something I'll do if I find some time, but would be happy to see someone else work on :-). -- Adam
[PATCH 4/8] man: clarify search --exclude documentation
I have reviewed all the new parts of this series (judged as being patches 3-8) and the changes made to my two patches and they are all fine (with one small comment below). Patch 1/8 does need a proper review though as it ended up more intrusive than I would have liked. > +Messages matching search.tag_exclude are called "excluded messages". My one comment is that this is not quite true if the corresponding tag is in the query. Since you are defining the term it would be nice to mention that, but I can't see a clean wording. This should not hold up the series as it your wording is clearly an improvement on the current wording. Best wishes Mark
Re: miraculous from: field
On Wed, Jun 20, 2012 at 5:33 AM, Jani Nikula wrote: > The reply template comes from 'notmuch reply' cli command, while the > forwarding is internal to the emacs ui. I don't have any quick solutions, > but perhaps in the long run we should do the forwarding template in the cli > too. I think this is the right approach. Someone suggested a while ago that we have a notmuch compose, which would do new message creation (for frontends that can't do it themselves), reply, and forward in one place. It would probably support raw and JSON like the current reply does. Something I'll do if I find some time, but would be happy to see someone else work on :-). -- Adam ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
miraculous from: field
Quoth David Belohrad on Jun 20 at 1:25 pm: > > Dear All, > > could someone give a hint? > > I have an opened mail message. When I press 'r' to reply, a new mail > buffer is opened and the 'From' field is correctly filled with > 'david at belohrad.ch'. > > When on the same message I press however 'f' to forward the message, new > buffer opens, but this time the 'From' field contains incorrectly > 'belohrad at bepc12494.cern.ch', which is clearly a composite of my login > name and FQHN. > > Why that difference and what can I do to mitigate this? Try setting Emacs's user-mail-address variable, e.g., using M-x customize-variableuser-mail-address You won't get the full from address guessing logic used for replies, but it's not obvious this is appropriate for forwarding. We should probably use the user's primary address from the notmuch configuration for this for the sake of consistency, even though user-mail-address is the more Emacsy thing to use. > thanks > > david
miraculous from: field
On Jun 20, 2012 2:25 PM, "David Belohrad" wrote: > > > Dear All, > > could someone give a hint? > > I have an opened mail message. When I press 'r' to reply, a new mail > buffer is opened and the 'From' field is correctly filled with > 'david at belohrad.ch'. > > When on the same message I press however 'f' to forward the message, new > buffer opens, but this time the 'From' field contains incorrectly > 'belohrad at bepc12494.cern.ch', which is clearly a composite of my login > name and FQHN. > > Why that difference and what can I do to mitigate this? The reply template comes from 'notmuch reply' cli command, while the forwarding is internal to the emacs ui. I don't have any quick solutions, but perhaps in the long run we should do the forwarding template in the cli too. > thanks > > david > ___ > notmuch mailing list > notmuch at notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch -- next part -- An HTML attachment was scrubbed... URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20120620/226efc55/attachment.html>
miraculous from: field
Dear All, could someone give a hint? I have an opened mail message. When I press 'r' to reply, a new mail buffer is opened and the 'From' field is correctly filled with 'david at belohrad.ch'. When on the same message I press however 'f' to forward the message, new buffer opens, but this time the 'From' field contains incorrectly 'belohrad at bepc12494.cern.ch', which is clearly a composite of my login name and FQHN. Why that difference and what can I do to mitigate this? thanks david
Re: [PATCH 4/8] man: clarify search --exclude documentation
I have reviewed all the new parts of this series (judged as being patches 3-8) and the changes made to my two patches and they are all fine (with one small comment below). Patch 1/8 does need a proper review though as it ended up more intrusive than I would have liked. > +Messages matching search.tag_exclude are called "excluded messages". My one comment is that this is not quite true if the corresponding tag is in the query. Since you are defining the term it would be nice to mention that, but I can't see a clean wording. This should not hold up the series as it your wording is clearly an improvement on the current wording. Best wishes Mark ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: miraculous from: field
Quoth David Belohrad on Jun 20 at 1:25 pm: > > Dear All, > > could someone give a hint? > > I have an opened mail message. When I press 'r' to reply, a new mail > buffer is opened and the 'From' field is correctly filled with > 'da...@belohrad.ch'. > > When on the same message I press however 'f' to forward the message, new > buffer opens, but this time the 'From' field contains incorrectly > 'beloh...@bepc12494.cern.ch', which is clearly a composite of my login > name and FQHN. > > Why that difference and what can I do to mitigate this? Try setting Emacs's user-mail-address variable, e.g., using M-x customize-variableuser-mail-address You won't get the full from address guessing logic used for replies, but it's not obvious this is appropriate for forwarding. We should probably use the user's primary address from the notmuch configuration for this for the sake of consistency, even though user-mail-address is the more Emacsy thing to use. > thanks > > david ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Notmuch Pick
On Tue, 19 Jun 2012 11:52:01 -0700, Jameson Graef Rollins wrote: > > So I think it would be nice and clean if the default json output > included all the message headers and the message structure, and then > part contents could be retrieved individually. I imagine show mode > could be restructured such that it could use this efficiently. Whatever is done, please keep the option to return all message bodies at once, at least for short threads (the common case). I want them anyway. Don't force me to make N separate requests, especially over a high latency link. Peter
[PATCH 8/8] cli: use notmuch_exclude_t in option parser
Use notmuch_exclude_t constants directly instead of a redundant enumeration while parsing search --exclude keyword arguments. --- notmuch-search.c | 28 +--- 1 files changed, 9 insertions(+), 19 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 027923d..23cf342 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -416,13 +416,6 @@ do_search_tags (notmuch_database_t *notmuch, return 0; } -enum { -EXCLUDE_TRUE, -EXCLUDE_FALSE, -EXCLUDE_FLAG, -EXCLUDE_ALL -}; - int notmuch_search_command (void *ctx, int argc, char *argv[]) { @@ -436,7 +429,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) output_t output = OUTPUT_SUMMARY; int offset = 0; int limit = -1; /* unlimited */ -int exclude = EXCLUDE_TRUE; +notmuch_exclude_t exclude = NOTMUCH_EXCLUDE_TRUE; unsigned int i; enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT } @@ -459,10 +452,10 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) { "tags", OUTPUT_TAGS }, { 0, 0 } } }, { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x', - (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, - { "false", EXCLUDE_FALSE }, - { "flag", EXCLUDE_FLAG }, - { "all", EXCLUDE_ALL }, + (notmuch_keyword_t []){ { "true", NOTMUCH_EXCLUDE_TRUE }, + { "false", NOTMUCH_EXCLUDE_FALSE }, + { "flag", NOTMUCH_EXCLUDE_FLAG }, + { "all", NOTMUCH_EXCLUDE_ALL }, { 0, 0 } } }, { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, @@ -510,15 +503,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) notmuch_query_set_sort (query, sort); -if (exclude == EXCLUDE_FLAG && output != OUTPUT_SUMMARY) { +if (exclude == NOTMUCH_EXCLUDE_FLAG && output != OUTPUT_SUMMARY) { /* If we are not doing summary output there is nowhere to * print the excluded flag so fall back on including the * excluded messages. */ fprintf (stderr, "Warning: this output format cannot flag excluded messages.\n"); - exclude = EXCLUDE_FALSE; + exclude = NOTMUCH_EXCLUDE_FALSE; } -if (exclude != EXCLUDE_FALSE) { +if (exclude != NOTMUCH_EXCLUDE_FALSE) { const char **search_exclude_tags; size_t search_exclude_tags_length; @@ -526,10 +519,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) (config, &search_exclude_tags_length); for (i = 0; i < search_exclude_tags_length; i++) notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); - if (exclude == EXCLUDE_FLAG) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FLAG); - if (exclude == EXCLUDE_ALL) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); + notmuch_query_set_omit_excluded (query, exclude); } switch (output) { -- 1.7.4.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 7/8] lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t
Add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t so that it can cover all four values of search --exclude in the cli. --- lib/notmuch.h|1 + lib/query.cc |6 -- notmuch-search.c |2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/notmuch.h b/lib/notmuch.h index 1280afd..f4381ae 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -504,6 +504,7 @@ notmuch_query_get_query_string (notmuch_query_t *query); typedef enum { NOTMUCH_EXCLUDE_FALSE, NOTMUCH_EXCLUDE_TRUE, +NOTMUCH_EXCLUDE_FLAG, NOTMUCH_EXCLUDE_ALL } notmuch_exclude_t; diff --git a/lib/query.cc b/lib/query.cc index f752452..1e0f292 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -221,10 +221,12 @@ notmuch_query_search_messages (notmuch_query_t *query) if (query->exclude_terms) { exclude_query = _notmuch_exclude_tags (query, final_query); - if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) + if (query->omit_excluded == NOTMUCH_EXCLUDE_TRUE || + query->omit_excluded == NOTMUCH_EXCLUDE_ALL) + { final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, final_query, exclude_query); - else { + } else { exclude_query = Xapian::Query (Xapian::Query::OP_AND, exclude_query, final_query); diff --git a/notmuch-search.c b/notmuch-search.c index 89b5bf9..027923d 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -527,7 +527,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) for (i = 0; i < search_exclude_tags_length; i++) notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); if (exclude == EXCLUDE_FLAG) - notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE); + notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FLAG); if (exclude == EXCLUDE_ALL) notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); } -- 1.7.4.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 6/8] man: document search --exclude=all
Document the new search --exclude=all option. --- man/man1/notmuch-search.1 |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 index e23ca30..1d8d57a 100644 --- a/man/man1/notmuch-search.1 +++ b/man/man1/notmuch-search.1 @@ -114,7 +114,7 @@ Limit the number of displayed results to N. .RS 4 .TP 4 -.BR \-\-exclude=(true|false|flag) +.BR \-\-exclude=(true|false|all|flag) Messages matching search.tag_exclude are called "excluded messages". This option specifies whether to omit excluded messages in the search @@ -124,6 +124,10 @@ The default value, .BR true , prevents excluded messages from matching the search terms. +.B all +additionally prevents excluded messages from appearing in displayed +results, in effect behaving as though the excluded messages do not exist. + .B false allows excluded messages to match search terms and appear in displayed results. Excluded messages are still marked in the relevant outputs. -- 1.7.4.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 5/8] man: clarify search --exclude=flag
Improve the description of the search --exclude=flag option, using text taken from the commit that introduced the option. --- man/man1/notmuch-search.1 |8 +--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 index 003b742..e23ca30 100644 --- a/man/man1/notmuch-search.1 +++ b/man/man1/notmuch-search.1 @@ -130,9 +130,11 @@ results. Excluded messages are still marked in the relevant outputs. .B flag only has an effect when -.B --output=summary -In this case all matching threads are returned but the "match count" -is the number of matching non-excluded messages in the thread. +.BR --output=summary . +The output is almost identical to +.BR false , +but the "match count" is the number of matching non-excluded messages in the +thread, rather than the number of matching messages. .RE .SH SEE ALSO -- 1.7.4.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/8] cli: add --exclude=all option to notmuch-search.c
From: Mark Walters Add a --exclude=all option to notmuch search. --- notmuch-search.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 3be296d..89b5bf9 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -420,6 +420,7 @@ enum { EXCLUDE_TRUE, EXCLUDE_FALSE, EXCLUDE_FLAG, +EXCLUDE_ALL }; int @@ -461,6 +462,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE }, { "false", EXCLUDE_FALSE }, { "flag", EXCLUDE_FLAG }, + { "all", EXCLUDE_ALL }, { 0, 0 } } }, { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 }, { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0 }, @@ -516,7 +518,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) exclude = EXCLUDE_FALSE; } -if (exclude == EXCLUDE_TRUE || exclude == EXCLUDE_FLAG) { +if (exclude != EXCLUDE_FALSE) { const char **search_exclude_tags; size_t search_exclude_tags_length; @@ -525,7 +527,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) for (i = 0; i < search_exclude_tags_length; i++) notmuch_query_add_tag_exclude (query, search_exclude_tags[i]); if (exclude == EXCLUDE_FLAG) - notmuch_query_set_omit_excluded (query, FALSE); + notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE); + if (exclude == EXCLUDE_ALL) + notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL); } switch (output) { -- 1.7.4.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 4/8] man: clarify search --exclude documentation
Highlight "excluded messages" as a piece of jargon with a meaning that may not be obvious. Be explicit about the effects of search --exclude=true and --exclude=false. --- man/man1/notmuch-search.1 | 14 -- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1 index 5c72c4b..003b742 100644 --- a/man/man1/notmuch-search.1 +++ b/man/man1/notmuch-search.1 @@ -116,8 +116,18 @@ Limit the number of displayed results to N. .TP 4 .BR \-\-exclude=(true|false|flag) -Specify whether to omit messages matching search.tag_exclude from the -search results (the default) or not. The extra option +Messages matching search.tag_exclude are called "excluded messages". +This option specifies whether to omit excluded messages in the search +process. + +The default value, +.BR true , +prevents excluded messages from matching the search terms. + +.B false +allows excluded messages to match search terms and appear in displayed +results. Excluded messages are still marked in the relevant outputs. + .B flag only has an effect when .B --output=summary -- 1.7.4.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 3/8] test: add tests for search --exclude=all
Test the new search --exclude=all option. --- test/excludes | 22 ++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/test/excludes b/test/excludes index 24d653e..f1ae9ea 100755 --- a/test/excludes +++ b/test/excludes @@ -166,6 +166,16 @@ ${matching_message_ids[3]} ${matching_message_ids[4]} ${matching_message_ids[5]}" +test_begin_subtest "Search, exclude=all (thread summary)" +output=$(notmuch search --exclude=all tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: reply 4 (inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; No messages excluded: single match: reply 3 (inbox test unread)" + +test_begin_subtest "Search, exclude=all (messages)" +output=$(notmuch search --exclude=all --output=messages tag:test | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[4]} +${matching_message_ids[5]}" + test_begin_subtest "Search, default exclusion: tag in query (thread summary)" output=$(notmuch search tag:test and tag:deleted | notmuch_search_sanitize) test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) @@ -218,6 +228,18 @@ ${matching_message_ids[1]} ${matching_message_ids[2]} ${matching_message_ids[3]}" +test_begin_subtest "Search, exclude=all: tag in query (thread summary)" +output=$(notmuch search --exclude=all tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; All messages excluded: single match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [2/6] Notmuch Test Suite; All messages excluded: double match: reply 2 (deleted inbox test unread) +thread:XXX 2001-01-05 [1/6] Notmuch Test Suite; Some messages excluded: single excluded match: reply 3 (deleted inbox test unread)" + +test_begin_subtest "Search, exclude=all: tag in query (messages)" +output=$(notmuch search --exclude=all --output=messages tag:test and tag:deleted | notmuch_search_sanitize) +test_expect_equal "$output" "${matching_message_ids[0]} +${matching_message_ids[1]} +${matching_message_ids[2]} +${matching_message_ids[3]}" # # Notmuch count tests -- 1.7.4.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 1/8] lib: add --exclude=all option
From: Mark Walters Adds a exclude all option to the lib which means that excluded messages are completely ignored (as if they had actually been deleted). --- lib/notmuch-private.h |1 + lib/notmuch.h | 22 +++--- lib/query.cc | 10 ++ lib/thread.cc | 41 ++--- 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index bfb4111..aa799b4 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -232,6 +232,7 @@ _notmuch_thread_create (void *ctx, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, notmuch_string_list_t *excluded_terms, + notmuch_exclude_t omit_exclude, notmuch_sort_t sort); /* message.cc */ diff --git a/lib/notmuch.h b/lib/notmuch.h index 3633bed..1280afd 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -500,14 +500,22 @@ typedef enum { const char * notmuch_query_get_query_string (notmuch_query_t *query); +/* Exclude values for notmuch_query_set_omit_excluded */ +typedef enum { +NOTMUCH_EXCLUDE_FALSE, +NOTMUCH_EXCLUDE_TRUE, +NOTMUCH_EXCLUDE_ALL +} notmuch_exclude_t; + /* Specify whether to omit excluded results or simply flag them. By * default, this is set to TRUE. * - * If this is TRUE, notmuch_query_search_messages will omit excluded - * messages from the results. notmuch_query_search_threads will omit - * threads that match only in excluded messages, but will include all - * messages in threads that match in at least one non-excluded - * message. + * If set to TRUE or ALL, notmuch_query_search_messages will omit excluded + * messages from the results, and notmuch_query_search_threads will omit + * threads that match only in excluded messages. If set to TRUE, + * notmuch_query_search_threads will include all messages in threads that + * match in at least one non-excluded message. Otherwise, if set to ALL, + * notmuch_query_search_threads will omit excluded messages from all threads. * * The performance difference when calling * notmuch_query_search_messages should be relatively small (and both @@ -516,9 +524,9 @@ notmuch_query_get_query_string (notmuch_query_t *query); * excluded messages as it does not need to construct the threads that * only match in excluded messages. */ - void -notmuch_query_set_omit_excluded (notmuch_query_t *query, notmuch_bool_t omit_excluded); +notmuch_query_set_omit_excluded (notmuch_query_t *query, +notmuch_exclude_t omit_excluded); /* Specify the sorting desired for this query. */ void diff --git a/lib/query.cc b/lib/query.cc index e9c1a2d..f752452 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -28,7 +28,7 @@ struct _notmuch_query { const char *query_string; notmuch_sort_t sort; notmuch_string_list_t *exclude_terms; -notmuch_bool_t omit_excluded; +notmuch_exclude_t omit_excluded; }; typedef struct _notmuch_mset_messages { @@ -92,7 +92,7 @@ notmuch_query_create (notmuch_database_t *notmuch, query->exclude_terms = _notmuch_string_list_create (query); -query->omit_excluded = TRUE; +query->omit_excluded = NOTMUCH_EXCLUDE_TRUE; return query; } @@ -104,7 +104,8 @@ notmuch_query_get_query_string (notmuch_query_t *query) } void -notmuch_query_set_omit_excluded (notmuch_query_t *query, notmuch_bool_t omit_excluded) +notmuch_query_set_omit_excluded (notmuch_query_t *query, +notmuch_exclude_t omit_excluded) { query->omit_excluded = omit_excluded; } @@ -220,7 +221,7 @@ notmuch_query_search_messages (notmuch_query_t *query) if (query->exclude_terms) { exclude_query = _notmuch_exclude_tags (query, final_query); - if (query->omit_excluded) + if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, final_query, exclude_query); else { @@ -486,6 +487,7 @@ notmuch_threads_get (notmuch_threads_t *threads) doc_id, &threads->match_set, threads->query->exclude_terms, + threads->query->omit_excluded, threads->query->sort); } diff --git a/lib/thread.cc b/lib/thread.cc index e976d64..4cb0896 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -215,7 +215,8 @@ _thread_cleanup_author (notmuch_thread_t *thread, static void _thread_add_message (notmuch_thread_t *thread, notmuch_message_t *message, -notmuch_string_list_t *exclude_terms) +notmuch_string_list_t *exclude_terms, +notmuch_exclude_t omit_exclude) { notmuch
[PATCH 0/8] search --exclude=all
Hi, This is Mark's change to add search --exclude=all. I mainly just updated a comment and added some documentation. Mark Walters (2): lib: add --exclude=all option cli: add --exclude=all option to notmuch-search.c Peter Wang (6): test: add tests for search --exclude=all man: clarify search --exclude documentation man: clarify search --exclude=flag man: document search --exclude=all lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t cli: use notmuch_exclude_t in option parser lib/notmuch-private.h |1 + lib/notmuch.h | 23 --- lib/query.cc | 14 +- lib/thread.cc | 41 ++--- man/man1/notmuch-search.1 | 28 ++-- notmuch-search.c | 24 +--- test/excludes | 22 ++ 7 files changed, 109 insertions(+), 44 deletions(-) -- 1.7.4.4 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: miraculous from: field
On Jun 20, 2012 2:25 PM, "David Belohrad" wrote: > > > Dear All, > > could someone give a hint? > > I have an opened mail message. When I press 'r' to reply, a new mail > buffer is opened and the 'From' field is correctly filled with > 'da...@belohrad.ch'. > > When on the same message I press however 'f' to forward the message, new > buffer opens, but this time the 'From' field contains incorrectly > 'beloh...@bepc12494.cern.ch', which is clearly a composite of my login > name and FQHN. > > Why that difference and what can I do to mitigate this? The reply template comes from 'notmuch reply' cli command, while the forwarding is internal to the emacs ui. I don't have any quick solutions, but perhaps in the long run we should do the forwarding template in the cli too. > thanks > > david > ___ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
miraculous from: field
Dear All, could someone give a hint? I have an opened mail message. When I press 'r' to reply, a new mail buffer is opened and the 'From' field is correctly filled with 'da...@belohrad.ch'. When on the same message I press however 'f' to forward the message, new buffer opens, but this time the 'From' field contains incorrectly 'beloh...@bepc12494.cern.ch', which is clearly a composite of my login name and FQHN. Why that difference and what can I do to mitigate this? thanks david ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch