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 2EC7F429E28 for ; Sat, 28 Jan 2012 16:03:31 -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 1XIOvgC1VpWy for ; Sat, 28 Jan 2012 16:03:30 -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 37A63431FCF for ; Sat, 28 Jan 2012 16:03:30 -0800 (PST) Received: by mail-we0-f181.google.com with SMTP id b10so2751672wer.26 for ; Sat, 28 Jan 2012 16:03:30 -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=nBzJtZ4zSaimCeB5V32DXI2qT7WcwbQ1JgB/R51C2Fc=; b=DLgtkGwT2D2GK5OKOzvFDHUIIrauWarx+CjJqplROdrjZ8C8OTjno1fcny8Z0cVcxC ZihHhRC3vuCVrGqYUhsLVpvny7VLS4cyPyjqM7p4CHzeFeaejLLZgeLPlR+Ib2tGvdob jm/lbyEBR+bWXYQORCZIZ1+vtzlUnZhPJlT74= Received: by 10.216.135.15 with SMTP id t15mr5026561wei.3.1327795409956; Sat, 28 Jan 2012 16:03:29 -0800 (PST) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id l6sm20810344wiv.11.2012.01.28.16.03.28 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 28 Jan 2012 16:03:29 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org, amdragon@MIT.EDU Subject: [PATCH 3/4] Add exclude flag Date: Sun, 29 Jan 2012 00:04:03 +0000 Message-Id: <1327795444-18745-3-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <8739azqt2j.fsf@qmul.ac.uk> References: <8739azqt2j.fsf@qmul.ac.uk> 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: Sun, 29 Jan 2012 00:03:31 -0000 Add the exclude flag to notmuch_query_search_threads --- lib/notmuch-private.h | 17 +++++++++++------ lib/query.cc | 1 + lib/thread.cc | 18 +++++++++++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h index 7bf153e..56b87c6 100644 --- a/lib/notmuch-private.h +++ b/lib/notmuch-private.h @@ -211,12 +211,8 @@ _notmuch_directory_get_document_id (notmuch_directory_t *directory); /* thread.cc */ -notmuch_thread_t * -_notmuch_thread_create (void *ctx, - notmuch_database_t *notmuch, - unsigned int seed_doc_id, - notmuch_doc_id_set_t *match_set, - notmuch_sort_t sort); +/* Definition of _notmuch_thread_create moved later since now uses + * string_list_t */ /* message.cc */ @@ -401,6 +397,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; }; @@ -491,6 +488,14 @@ notmuch_filenames_t * _notmuch_filenames_create (const void *ctx, notmuch_string_list_t *list); +notmuch_thread_t * +_notmuch_thread_create (void *ctx, + notmuch_database_t *notmuch, + unsigned int seed_doc_id, + notmuch_doc_id_set_t *match_set, + notmuch_string_list_t *excluded_terms, + notmuch_sort_t sort); + #pragma GCC visibility pop NOTMUCH_END_DECLS diff --git a/lib/query.cc b/lib/query.cc index 8ffafe5..de95745 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -456,6 +456,7 @@ notmuch_threads_get (notmuch_threads_t *threads) threads->query->notmuch, doc_id, &threads->match_set, + threads->query->exclude_terms, threads->query->sort); } diff --git a/lib/thread.cc b/lib/thread.cc index 0435ee6..6d65d52 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread, */ static void _thread_add_message (notmuch_thread_t *thread, - notmuch_message_t *message) + notmuch_message_t *message, + notmuch_string_list_t *exclude_terms) { notmuch_tags_t *tags; const char *tag; @@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread, notmuch_tags_move_to_next (tags)) { tag = notmuch_tags_get (tags); + /* mark excluded messages */ + for (notmuch_string_node_t *term = exclude_terms->head; term; + term = term->next) { + /* we ignore initial 'K' */ + if (strcmp(tag, (term->string + 1)) == 0) { + notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE); + break; + } + } g_hash_table_insert (thread->tags, xstrdup (tag), NULL); } } @@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread, _thread_set_subject_from_message (thread, message); } - thread->matched_messages++; + if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED)) + thread->matched_messages++; if (g_hash_table_lookup_extended (thread->message_hash, notmuch_message_get_message_id (message), NULL, @@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx, notmuch_database_t *notmuch, unsigned int seed_doc_id, notmuch_doc_id_set_t *match_set, + notmuch_string_list_t *exclude_terms, notmuch_sort_t sort) { notmuch_thread_t *thread; @@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx, if (doc_id == seed_doc_id) message = seed_message; - _thread_add_message (thread, message); + _thread_add_message (thread, message, exclude_terms); if ( _notmuch_doc_id_set_contains (match_set, doc_id)) { _notmuch_doc_id_set_remove (match_set, doc_id); -- 1.7.2.3