Here is the latest version of this patch set. I think I have fixed most of the problems raised in review but there are some remaining issues detailed below.
Changes and queries: 1) Changed --do-not-exclude option to --no-exclude 2) The api notmuch_query_set_omit_excluded_messages remains: without it I can't see how a user can pass the notmuch_messages_t object around which does not contain the excluded messages. See id:"87fweusabh.fsf at qmul.ac.uk" 3) I have introduced a new function notmuch_thread_get_flag_messages (notmuch_thread_t *thread, unsigned int flag_mask, unsigned int flags) which returns the number of messages with the specified flags on flag_mask. (Note the current NOTMUCH_MESSAGE_FLAGs were nominally the bit position of the flag rather than the actual bit of the flag. I changed that. I am not completely happy with the style for this commit (patch 7/11): any comments gratefully received! 4) In id:"20120131044352.GZ17991 at mit.edu" Austin suggested that I use a notmuch_mset_messages_t object rather than an notmuch_doc_id_set_t. I couldn't see how that would work unless the iterator would generate the excludes in step with the main query. At the moment the doc_id object just stores a bitmap listing all relevant excluded messages. 5) If we have a query which overrides the excludes such as "blah and tag:deleted" should the tag:deleted messages still be marked excluded? The current implementation does mark them excluded but my preference would be not to. What do people think? 6) In id:"20120131050748.GA10844 at mit.edu" Austin pointed out that the sort will be influenced by the excluded messages. I do not think either of us are sure whether it should be or not so I have left it as is for the moment. Best wishes Mark