From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 03DC4429E54 for ; Mon, 23 Jan 2012 17:18:00 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q-h42cVjiX2o for ; Mon, 23 Jan 2012 17:17:59 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 38C38429E21 for ; Mon, 23 Jan 2012 17:17:59 -0800 (PST) Received: by wibhi8 with SMTP id hi8so1161947wib.26 for ; Mon, 23 Jan 2012 17:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=rEKevW81/FvrhICXMDswPT1+GKxqnoO9U6ITlyI+hcg=; b=eWjJKOtzrf4XHAd41XupCKHwH+qfUSav58OINAYHc45dS9/TvM0p8HxTkZ48LDjh9e jfVpLX0m+X16ID6Hqo467973rzT/+gC8mFvh1RYHzEg0Kve/BQ1T/mINsJPAcdFQox0X qKQ0bjh+JJYpOxxQPpBJtZmI4SSSV2oacC1Ws= Received: by 10.181.13.208 with SMTP id fa16mr17341233wid.12.1327367878131; Mon, 23 Jan 2012 17:17:58 -0800 (PST) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id dr5sm47008406wib.0.2012.01.23.17.17.56 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Jan 2012 17:17:57 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org, Austin Clements Subject: [RFC PATCH 2/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Date: Tue, 24 Jan 2012 01:18:41 +0000 Message-Id: <1327367923-18228-2-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <20120124011609.GX16740@mit.edu> References: <20120124011609.GX16740@mit.edu> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jan 2012 01:18:00 -0000 Form excluded doc_ids set and use that to exclude messages. Should be no functional change. --- lib/notmuch-private.h | 1 + lib/query.cc | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 7bf153e..e791bb0 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -401,6 +401,7 @@ typedef struct _notmuch_message_list { */ struct visible _notmuch_messages { notmuch_bool_t is_of_list_type; + notmuch_doc_id_set_t *excluded_doc_ids; notmuch_message_node_t *iterator; }; diff --git a/lib/query.cc b/lib/query.cc index c25b301..92fa834 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -57,6 +57,11 @@ struct visible _notmuch_threads { notmuch_doc_id_set_t match_set; }; +static notmuch_bool_t +_notmuch_doc_id_set_init (void *ctx, + notmuch_doc_id_set_t *doc_ids, + GArray *arr); + notmuch_query_t * notmuch_query_create (notmuch_database_t *notmuch, const char *query_string) @@ -173,6 +178,7 @@ notmuch_query_search_messages (notmuch_query_t *query) "mail")); Xapian::Query string_query, final_query, exclude_query; Xapian::MSet mset; + Xapian::MSetIterator iterator; unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_PHRASE | Xapian::QueryParser::FLAG_LOVEHATE | @@ -193,8 +199,21 @@ notmuch_query_search_messages (notmuch_query_t *query) exclude_query = _notmuch_exclude_tags (query, final_query); - final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, - final_query, exclude_query); + enquire.set_weighting_scheme (Xapian::BoolWeight()); + enquire.set_query (exclude_query); + + mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ()); + + GArray *excluded_doc_ids = g_array_new (FALSE, FALSE, sizeof (unsigned int)); + + for (iterator = mset.begin (); iterator != mset.end (); iterator++) + { + unsigned int doc_id = *iterator; + g_array_append_val (excluded_doc_ids, doc_id); + } + messages->base.excluded_doc_ids = talloc (query, _notmuch_doc_id_set); + _notmuch_doc_id_set_init (query, messages->base.excluded_doc_ids, + excluded_doc_ids); enquire.set_weighting_scheme (Xapian::BoolWeight()); @@ -294,6 +313,11 @@ _notmuch_mset_messages_move_to_next (notmuch_messages_t *messages) mset_messages = (notmuch_mset_messages_t *) messages; mset_messages->iterator++; + + while ((mset_messages->iterator != mset_messages->iterator_end) && + (_notmuch_doc_id_set_contains (messages->excluded_doc_ids, + *mset_messages->iterator))) + mset_messages->iterator++; } static notmuch_bool_t -- 1.7.2.3