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 8F25F431E64 for ; Mon, 30 Jan 2012 20:51:15 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 1.075 X-Spam-Level: * X-Spam-Status: No, score=1.075 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7, URIBL_BLACK=1.775] 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 h4AXolSkOs8h for ; Mon, 30 Jan 2012 20:51:14 -0800 (PST) Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU [18.7.68.36]) by olra.theworths.org (Postfix) with ESMTP id B193F431FBC for ; Mon, 30 Jan 2012 20:51:14 -0800 (PST) X-AuditID: 12074424-b7fae6d000000906-c6-4f2773429b1e Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP id C3.1A.02310.243772F4; Mon, 30 Jan 2012 23:51:14 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q0V4pDC8016020; Mon, 30 Jan 2012 23:51:14 -0500 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0V4pCv8001110 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 30 Jan 2012 23:51:13 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1Rs5fg-0002mn-Rg; Mon, 30 Jan 2012 23:50:20 -0500 Date: Mon, 30 Jan 2012 23:50:20 -0500 From: Austin Clements To: Mark Walters Subject: Re: [PATCH 4/7] lib: Add the exclude flag to notmuch_query_search_threads Message-ID: <20120131045020.GA17991@mit.edu> References: <8762fu4aqt.fsf@qmul.ac.uk> <1327862394-14334-4-git-send-email-markwalters1009@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1327862394-14334-4-git-send-email-markwalters1009@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnleLIzCtJLcpLzFFi42IRYrdT0XUqVvc3aHgiYLF6Lo/F9ZszmR2Y PHbOusvu8WzVLeYApigum5TUnMyy1CJ9uwSujPkXNjAXbFeq+P70IlsD40TpLkZODgkBE4lN V1ewQ9hiEhfurWfrYuTiEBLYxyhx8uIKKGcDo8SdPydYIJyTTBLHVvWwQzhLGCU6WvexgPSz CKhKdJ08wwpiswloSGzbv5wRxBYR0JG4fWgB2A5mAWmJb7+bmUBsYYEQiccf94HV8wLVXNjU BRYXEkiX2Pz8LQtEXFDi5MwnLBC9WhI3/r0EquEAm7P8HwdImFPAS2LD9V6w8aICKhJTTm5j m8AoNAtJ9ywk3bMQuhcwMq9ilE3JrdLNTczMKU5N1i1OTszLSy3SNdfLzSzRS00p3cQIDmsX lR2MzYeUDjEKcDAq8fAKfVLzF2JNLCuuzD3EKMnBpCTKO6dA3V+ILyk/pTIjsTgjvqg0J7X4 EKMEB7OSCO+b1UDlvCmJlVWpRfkwKWkOFiVxXg2td35A/yaWpGanphakFsFkZTg4lCR424qA hgoWpaanVqRl5pQgpJk4OEGG8wAN3wtSw1tckJhbnJkOkT/FqMvR/nb3eUYhlrz8vFQpcd6F IEUCIEUZpXlwc2Dp6BWjONBbwrxLQKp4gKkMbtIroCVMQEueM6iCLClJREhJNTCu3hv/LexN wk23CcEnP+8Uv8aRYNizfF5085+pkTMq7G9cUZs+/2TApKUvbmRu+OL9rYDrxaVr7ZfYQrRf /Is98yRop2HCBL4Wh6fK5onmV1xubrsetkfxScPnQL8MtpquREatdTwbjb+m5z/6/8dy0evD KuyeC8WWf1th+HRnY8kXtcKnAhOslViKMxINtZiLihMBGXa/PiIDAAA= Cc: notmuch@notmuchmail.org 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, 31 Jan 2012 04:51:15 -0000 Quoth Mark Walters on Jan 29 at 6:39 pm: > Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to > notmuch_query_search_threads. Implemented by inspecting the tags > directly in _notmuch_thread_create/_thread_add_message rather than as > a Xapian query for speed reasons. > --- > lib/notmuch-private.h | 16 ++++++++++------ > lib/query.cc | 1 + > lib/thread.cc | 18 +++++++++++++++--- > 3 files changed, 26 insertions(+), 9 deletions(-) > > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h > index e791bb0..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 */ Naw, leave the definition here along with the other things from thread.cc and just add a typedef struct _notmuch_string_list notmuch_string_list_t; along with the typedef for notmuch_doc_id_set_t near the top. (You might also have to tweak the typedef of notmuch_string_list_t later so it's just the struct definition.) > > /* message.cc */ > > @@ -492,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 7d165d2..dee7ec0 100644 > --- a/lib/query.cc > +++ b/lib/query.cc > @@ -472,6 +472,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 */ Capital and period. > + for (notmuch_string_node_t *term = exclude_terms->head; term; > + term = term->next) { > + /* we ignore initial 'K' */ Same. > + 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++; I'd still say this warrants a better API. > > 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);