Notmuch Pick
Hi Since I have had various requests for notmuch pick (id:1329096015-8078-2-git-send-email-markwalters1...@gmail.com) so I have started a git repository at git://github.com/markwalters1009/notmuch.git The branch pick-6 is the current version. My intention is to start a new branch each time I rebase on to current master but this may change. (I suggest that people do not rely on a consistent history for this repository) My intention is to try and get pick into mainline: there is a current series id:1339842107-10632-1-git-send-email-markwalters1...@gmail.com (allowing notmuch show --format=json to return non-entire threads). This is the first chunk of the pick set. After that series there are some small emacs changes (primarily entry points to pick), some small changes (25 lines of diff) to the core C code, and the notmuch-pick.el file itself. The plan is to put a stub notmuch-pick.el file into the main notmuch repository and keep the real notmuch-pick.el in contrib until it becomes good enough to be acceptable in mainline. Patches, comments, reviews etc are all gratefully received! USE OF PICK This is just a quick introduction to the commands for pick: the two main entry points are 'z' to start a notmuch pick search, and 'Z' to display the current search or show in pick form. Once in pick mode RET displays the message in a split-pane window or M-RET opens it in a new full-window buffer. Once in pick-mode '?' should document all the available commands. Best wishes Mark ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: search summary and exclusions
On Wed, 30 May 2012 08:49:31 +0100, Mark Walters markwalters1...@gmail.com wrote: On Wed, 30 May 2012, Peter Wang noval...@gmail.com wrote: Maybe there is room for another keyword under --exclude? Yes that might be the best way to go. Something like --exclude=all and then excluded messages never appear anywhere? I think it should be easy: I will try to send a patch tonight. Hi Mark, Did you get a chance to try this? Otherwise I can have a look. Peter ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Re: search summary and exclusions
On Sun, 17 Jun 2012, Peter Wang noval...@gmail.com wrote: On Wed, 30 May 2012 08:49:31 +0100, Mark Walters markwalters1...@gmail.com wrote: On Wed, 30 May 2012, Peter Wang noval...@gmail.com wrote: Maybe there is room for another keyword under --exclude? Yes that might be the best way to go. Something like --exclude=all and then excluded messages never appear anywhere? I think it should be easy: I will try to send a patch tonight. Hi Mark, Did you get a chance to try this? Otherwise I can have a look. Hi sorry I did try this but got distracted. Doing it neatly turned out to be a bit bigger than I expected. I will post what I had as a reply to this message, but I don't think I will be able to work on it any time soon so feel free to take it over. I think it all works but I have not tested it very much. Best wishes Mark ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[WIP 1/2] lib: add --exclude=all option
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 |3 ++- lib/notmuch.h | 10 +- lib/query.cc | 11 ++- lib/thread.cc | 41 + 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index bfb4111..3b92ac2 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -232,7 +232,8 @@ _notmuch_thread_create (void *ctx, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, notmuch_string_list_t *excluded_terms, - notmuch_sort_t sort); + notmuch_sort_t sort, + notmuch_exclude_t omit_exclude); /* message.cc */ diff --git a/lib/notmuch.h b/lib/notmuch.h index 3633bed..57cc700 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -500,6 +500,14 @@ 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. * @@ -518,7 +526,7 @@ 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); /* Specify the sorting desired for this query. */ void diff --git a/lib/query.cc b/lib/query.cc index e9c1a2d..fea76f8 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,7 @@ 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 +220,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,7 +486,8 @@ notmuch_threads_get (notmuch_threads_t *threads) doc_id, threads-match_set, threads-query-exclude_terms, - threads-query-sort); + threads-query-sort, + threads-query-omit_excluded); } void diff --git a/lib/thread.cc b/lib/thread.cc index e976d64..6b52792 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 *tags; const char *tag; @@ -223,6 +224,26 @@ _thread_add_message (notmuch_thread_t *thread, InternetAddress *address; const char *from, *author; char *clean_author; +notmuch_bool_t message_excluded = FALSE; + +for (tags = notmuch_message_get_tags (message); +notmuch_tags_valid (tags); +notmuch_tags_move_to_next (tags)) +{ + tag = notmuch_tags_get (tags); + /* Is message excluded. */ + for (notmuch_string_node_t *term = exclude_terms-head; term; +term = term-next) { + /* We ignore initial 'K'. */ + if (strcmp(tag, (term-string + 1)) == 0) { + message_excluded = TRUE; + break; + } + } +} + +if (message_excluded omit_exclude == NOTMUCH_EXCLUDE_ALL) + return; _notmuch_message_list_add_message (thread-message_list, talloc_steal (thread,
[WIP 2/2] cli: add --exclude=all option to notmuch-search.c
Add a --exclude=all option to notmuch search. --- notmuch-search.c |8 ++-- test/excludes|5 + 2 files changed, 11 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) { diff --git a/test/excludes b/test/excludes index 24d653e..7be8d79 100755 --- a/test/excludes +++ b/test/excludes @@ -166,6 +166,11 @@ ${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, 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) -- 1.7.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
Notmuch Pick
Hi Since I have had various requests for notmuch pick (id:"1329096015-8078-2-git-send-email-markwalters1009 at gmail.com") so I have started a git repository at git://github.com/markwalters1009/notmuch.git The branch pick-6 is the current version. My intention is to start a new branch each time I rebase on to current master but this may change. (I suggest that people do not rely on a consistent history for this repository) My intention is to try and get pick into mainline: there is a current series id:"1339842107-10632-1-git-send-email-markwalters1009 at gmail.com" (allowing notmuch show --format=json to return non-entire threads). This is the first chunk of the pick set. After that series there are some small emacs changes (primarily entry points to pick), some small changes (25 lines of diff) to the core C code, and the notmuch-pick.el file itself. The plan is to put a stub notmuch-pick.el file into the main notmuch repository and keep the real notmuch-pick.el in contrib until it becomes good enough to be acceptable in mainline. Patches, comments, reviews etc are all gratefully received! USE OF PICK This is just a quick introduction to the commands for pick: the two main entry points are 'z' to start a notmuch pick "search", and 'Z' to display the current search or "show" in pick form. Once in pick mode RET displays the message in a split-pane window or M-RET opens it in a new full-window buffer. Once in pick-mode '?' should document all the available commands. Best wishes Mark
search summary and exclusions
On Wed, 30 May 2012 08:49:31 +0100, Mark Walters wrote: > > On Wed, 30 May 2012, Peter Wang wrote: > > > > Maybe there is room for another keyword under --exclude? > > Yes that might be the best way to go. Something like --exclude=all and > then excluded messages never appear anywhere? > > I think it should be easy: I will try to send a patch tonight. Hi Mark, Did you get a chance to try this? Otherwise I can have a look. Peter
search summary and exclusions
On Sun, 17 Jun 2012, Peter Wang wrote: > On Wed, 30 May 2012 08:49:31 +0100, Mark Walters gmail.com> wrote: >> >> On Wed, 30 May 2012, Peter Wang wrote: >> > >> > Maybe there is room for another keyword under --exclude? >> >> Yes that might be the best way to go. Something like --exclude=all and >> then excluded messages never appear anywhere? >> >> I think it should be easy: I will try to send a patch tonight. > > Hi Mark, > > Did you get a chance to try this? Otherwise I can have a look. Hi sorry I did try this but got distracted. Doing it neatly turned out to be a bit bigger than I expected. I will post what I had as a reply to this message, but I don't think I will be able to work on it any time soon so feel free to take it over. I think it all works but I have not tested it very much. Best wishes Mark
[WIP 1/2] lib: add --exclude=all option
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 |3 ++- lib/notmuch.h | 10 +- lib/query.cc | 11 ++- lib/thread.cc | 41 + 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index bfb4111..3b92ac2 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -232,7 +232,8 @@ _notmuch_thread_create (void *ctx, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, notmuch_string_list_t *excluded_terms, - notmuch_sort_t sort); + notmuch_sort_t sort, + notmuch_exclude_t omit_exclude); /* message.cc */ diff --git a/lib/notmuch.h b/lib/notmuch.h index 3633bed..57cc700 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -500,6 +500,14 @@ 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. * @@ -518,7 +526,7 @@ 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); /* Specify the sorting desired for this query. */ void diff --git a/lib/query.cc b/lib/query.cc index e9c1a2d..fea76f8 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,7 @@ 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 +220,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,7 +486,8 @@ notmuch_threads_get (notmuch_threads_t *threads) doc_id, >match_set, threads->query->exclude_terms, - threads->query->sort); + threads->query->sort, + threads->query->omit_excluded); } void diff --git a/lib/thread.cc b/lib/thread.cc index e976d64..6b52792 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 *tags; const char *tag; @@ -223,6 +224,26 @@ _thread_add_message (notmuch_thread_t *thread, InternetAddress *address; const char *from, *author; char *clean_author; +notmuch_bool_t message_excluded = FALSE; + +for (tags = notmuch_message_get_tags (message); +notmuch_tags_valid (tags); +notmuch_tags_move_to_next (tags)) +{ + tag = notmuch_tags_get (tags); + /* Is message excluded. */ + for (notmuch_string_node_t *term = exclude_terms->head; term; +term = term->next) { + /* We ignore initial 'K'. */ + if (strcmp(tag, (term->string + 1)) == 0) { + message_excluded = TRUE; + break; + } + } +} + +if (message_excluded && omit_exclude == NOTMUCH_EXCLUDE_ALL) + return; _notmuch_message_list_add_message (thread->message_list, talloc_steal (thread,
[WIP 2/2] cli: add --exclude=all option to notmuch-search.c
Add a --exclude=all option to notmuch search. --- notmuch-search.c |8 ++-- test/excludes|5 + 2 files changed, 11 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", 'O', 0 }, { NOTMUCH_OPT_INT, , "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) { diff --git a/test/excludes b/test/excludes index 24d653e..7be8d79 100755 --- a/test/excludes +++ b/test/excludes @@ -166,6 +166,11 @@ ${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, 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) -- 1.7.9.1