From: Mark Walters Date: Tue, 31 Jan 2012 11:47:35 +0000 (+0000) Subject: Re: [PATCH 4/7] lib: Add the exclude flag to notmuch_query_search_threads X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=9a2caaead9ff9f8e11600f7e2a452ef742ec375d;p=notmuch-archives.git Re: [PATCH 4/7] lib: Add the exclude flag to notmuch_query_search_threads --- diff --git a/0f/7c3be67dae195912e79fd9c7da9404600e61ca b/0f/7c3be67dae195912e79fd9c7da9404600e61ca new file mode 100644 index 000000000..dcf47ab51 --- /dev/null +++ b/0f/7c3be67dae195912e79fd9c7da9404600e61ca @@ -0,0 +1,219 @@ +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 8CDD0431E64 + for ; Tue, 31 Jan 2012 03:46:32 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 a-39DRcVJUfz for ; + Tue, 31 Jan 2012 03:46:31 -0800 (PST) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 92122429E34 + for ; Tue, 31 Jan 2012 03:46:31 -0800 (PST) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1RsCAP-0004sm-OF; Tue, 31 Jan 2012 11:46:30 +0000 +Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] + helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1RsCAP-0006pT-Bo; Tue, 31 Jan 2012 11:46:29 +0000 +From: Mark Walters +To: Austin Clements +Subject: Re: [PATCH 4/7] lib: Add the exclude flag to + notmuch_query_search_threads +In-Reply-To: <20120131045020.GA17991@mit.edu> +References: <8762fu4aqt.fsf@qmul.ac.uk> + <1327862394-14334-4-git-send-email-markwalters1009@gmail.com> + <20120131045020.GA17991@mit.edu> +User-Agent: Notmuch/0.11+137~g98adc3d (http://notmuchmail.org) Emacs/23.2.1 + (i486-pc-linux-gnu) +Date: Tue, 31 Jan 2012 11:47:35 +0000 +Message-ID: <87vcnsccvc.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 94.192.233.223 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: a02fe2a1a8b3d601adbe665bd043bd79 (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * 0.5 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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 11:46:32 -0000 + +On Mon, 30 Jan 2012 23:50:20 -0500, Austin Clements wrote: +> 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.) + +Will do. + +> > /* 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. + +Will fix. + +> > + for (notmuch_string_node_t *term = exclude_terms->head; term; +> > + term = term->next) { +> > + /* we ignore initial 'K' */ +> +> Same. + +Will fix + +> > + 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. + +I agree: I will think about that. + +> > 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);