Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0F314429E5B for ; Mon, 23 Jan 2012 17:18:05 -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 7W1WURL22POg for ; Mon, 23 Jan 2012 17:18:04 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 16865429E21 for ; Mon, 23 Jan 2012 17:18:03 -0800 (PST) Received: by mail-we0-f181.google.com with SMTP id b10so3021166wer.26 for ; Mon, 23 Jan 2012 17:18:03 -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=b5Y71ehYOoKb21r8nlMS0pwVs0cFF3DGqhex70sZZTc=; b=syj9InI3ddjkpN7H+btzohd/NvenxlWsK+hek0eW8VDYSDGtQmp1ZZIBwTjLAJ1j1w LsmI3SKbub4kYMegHQDInn4fjZU3qgie4VY5jJWSZqoD8HzYbHAh/CPT/nQq48soMVV/ 5Etf5AhCXk/ghP+sgdPkjX0JeadT6TQbtE/i0= Received: by 10.216.138.101 with SMTP id z79mr31918wei.7.1327367883800; Mon, 23 Jan 2012 17:18:03 -0800 (PST) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id hc10sm12828949wib.8.2012.01.23.17.18.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Jan 2012 17:18:02 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org, Austin Clements Subject: [RFC PATCH 3/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag Date: Tue, 24 Jan 2012 01:18:42 +0000 Message-Id: <1327367923-18228-3-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:05 -0000 Add the actual NOTMUCH_MESSAGE_FLAG_EXCLUDED flag. --- lib/notmuch-private.h | 1 + lib/notmuch.h | 3 ++- lib/query.cc | 11 +++++++---- lib/thread.cc | 14 ++++++++++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index e791bb0..cb3eca6 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -216,6 +216,7 @@ _notmuch_thread_create (void *ctx, notmuch_database_t *notmuch, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, + notmuch_doc_id_set_t *excluded_doc_ids, notmuch_sort_t sort); /* message.cc */ diff --git a/lib/notmuch.h b/lib/notmuch.h index 7929fe7..cf0d45d 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -895,7 +895,8 @@ notmuch_message_get_filenames (notmuch_message_t *message); /* Message flags */ typedef enum _notmuch_message_flag { - NOTMUCH_MESSAGE_FLAG_MATCH + NOTMUCH_MESSAGE_FLAG_MATCH, + NOTMUCH_MESSAGE_FLAG_EXCLUDED } notmuch_message_flag_t; /* Get a value of a flag for the email corresponding to 'message'. */ diff --git a/lib/query.cc b/lib/query.cc index 92fa834..69e32bd 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -55,6 +55,7 @@ struct visible _notmuch_threads { /* The set of matched docid's that have not been assigned to a * thread. Initially, this contains every docid in doc_ids. */ notmuch_doc_id_set_t match_set; + notmuch_doc_id_set_t *excluded_doc_ids; }; static notmuch_bool_t @@ -302,6 +303,9 @@ _notmuch_mset_messages_get (notmuch_messages_t *messages) INTERNAL_ERROR ("a messages iterator contains a non-existent document ID.\n"); } + if (_notmuch_doc_id_set_contains (messages->excluded_doc_ids, doc_id)) + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE); + return message; } @@ -314,10 +318,6 @@ _notmuch_mset_messages_move_to_next (notmuch_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 @@ -403,6 +403,8 @@ notmuch_query_search_threads (notmuch_query_t *query) notmuch_messages_move_to_next (messages); } threads->doc_id_pos = 0; + /* the excluded messages are in query context so this should be ok */ + threads->excluded_doc_ids = messages->excluded_doc_ids; talloc_free (messages); @@ -452,6 +454,7 @@ notmuch_threads_get (notmuch_threads_t *threads) threads->query->notmuch, doc_id, &threads->match_set, + threads->excluded_doc_ids, threads->query->sort); } diff --git a/lib/thread.cc b/lib/thread.cc index 0435ee6..6ea2a44 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -302,7 +302,8 @@ _thread_set_subject_from_message (notmuch_thread_t *thread, static void _thread_add_matched_message (notmuch_thread_t *thread, notmuch_message_t *message, - notmuch_sort_t sort) + notmuch_sort_t sort, + notmuch_bool_t excluded) { time_t date; notmuch_message_t *hashed_message; @@ -321,7 +322,8 @@ _thread_add_matched_message (notmuch_thread_t *thread, _thread_set_subject_from_message (thread, message); } - thread->matched_messages++; + if (!excluded) + thread->matched_messages++; if (g_hash_table_lookup_extended (thread->message_hash, notmuch_message_get_message_id (message), NULL, @@ -392,6 +394,7 @@ _notmuch_thread_create (void *ctx, notmuch_database_t *notmuch, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, + notmuch_doc_id_set_t *excluded_doc_ids, notmuch_sort_t sort) { notmuch_thread_t *thread; @@ -456,7 +459,9 @@ _notmuch_thread_create (void *ctx, * oldest or newest subject is desired. */ notmuch_query_set_sort (thread_id_query, NOTMUCH_SORT_OLDEST_FIRST); - for (messages = notmuch_query_search_messages (thread_id_query); + messages = notmuch_query_search_messages (thread_id_query); + messages->excluded_doc_ids = excluded_doc_ids; + for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { @@ -471,7 +476,8 @@ _notmuch_thread_create (void *ctx, if ( _notmuch_doc_id_set_contains (match_set, doc_id)) { _notmuch_doc_id_set_remove (match_set, doc_id); - _thread_add_matched_message (thread, message, sort); + _thread_add_matched_message (thread, message, sort, + _notmuch_doc_id_set_contains (excluded_doc_ids, doc_id)); } _notmuch_message_close (message); -- 1.7.2.3