Re: [PATCH 4/7] lib: Add the exclude flag to notmuch_query_search_threads
authorAustin Clements <amdragon@MIT.EDU>
Tue, 31 Jan 2012 04:50:20 +0000 (23:50 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:45 +0000 (09:43 -0800)
56/1caf4abac9dbd1c57ebf2beea17a086bfd0713 [new file with mode: 0644]

diff --git a/56/1caf4abac9dbd1c57ebf2beea17a086bfd0713 b/56/1caf4abac9dbd1c57ebf2beea17a086bfd0713
new file mode 100644 (file)
index 0000000..0efea5d
--- /dev/null
@@ -0,0 +1,211 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 8F25F431E64\r
+       for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 20:51:15 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.075\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.075 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7, URIBL_BLACK=1.775] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id h4AXolSkOs8h for <notmuch@notmuchmail.org>;\r
+       Mon, 30 Jan 2012 20:51:14 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
+       [18.7.68.36])\r
+       by olra.theworths.org (Postfix) with ESMTP id B193F431FBC\r
+       for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 20:51:14 -0800 (PST)\r
+X-AuditID: 12074424-b7fae6d000000906-c6-4f2773429b1e\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id C3.1A.02310.243772F4; Mon, 30 Jan 2012 23:51:14 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q0V4pDC8016020; \r
+       Mon, 30 Jan 2012 23:51:14 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0V4pCv8001110\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Mon, 30 Jan 2012 23:51:13 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1Rs5fg-0002mn-Rg; Mon, 30 Jan 2012 23:50:20 -0500\r
+Date: Mon, 30 Jan 2012 23:50:20 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH 4/7] lib: Add the exclude flag to\r
+       notmuch_query_search_threads\r
+Message-ID: <20120131045020.GA17991@mit.edu>\r
+References: <8762fu4aqt.fsf@qmul.ac.uk>\r
+       <1327862394-14334-4-git-send-email-markwalters1009@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1327862394-14334-4-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFupnleLIzCtJLcpLzFFi42IRYrdT0XUqVvc3aHgiYLF6Lo/F9ZszmR2Y\r
+       PHbOusvu8WzVLeYApigum5TUnMyy1CJ9uwSujPkXNjAXbFeq+P70IlsD40TpLkZODgkBE4lN\r
+       V1ewQ9hiEhfurWfrYuTiEBLYxyhx8uIKKGcDo8SdPydYIJyTTBLHVvWwQzhLGCU6WvexgPSz\r
+       CKhKdJ08wwpiswloSGzbv5wRxBYR0JG4fWgB2A5mAWmJb7+bmUBsYYEQiccf94HV8wLVXNjU\r
+       BRYXEkiX2Pz8LQtEXFDi5MwnLBC9WhI3/r0EquEAm7P8HwdImFPAS2LD9V6w8aICKhJTTm5j\r
+       m8AoNAtJ9ywk3bMQuhcwMq9ilE3JrdLNTczMKU5N1i1OTszLSy3SNdfLzSzRS00p3cQIDmsX\r
+       lR2MzYeUDjEKcDAq8fAKfVLzF2JNLCuuzD3EKMnBpCTKO6dA3V+ILyk/pTIjsTgjvqg0J7X4\r
+       EKMEB7OSCO+b1UDlvCmJlVWpRfkwKWkOFiVxXg2td35A/yaWpGanphakFsFkZTg4lCR424qA\r
+       hgoWpaanVqRl5pQgpJk4OEGG8wAN3wtSw1tckJhbnJkOkT/FqMvR/nb3eUYhlrz8vFQpcd6F\r
+       IEUCIEUZpXlwc2Dp6BWjONBbwrxLQKp4gKkMbtIroCVMQEueM6iCLClJREhJNTCu3hv/LexN\r
+       wk23CcEnP+8Uv8aRYNizfF5085+pkTMq7G9cUZs+/2TApKUvbmRu+OL9rYDrxaVr7ZfYQrRf\r
+       /Is98yRop2HCBL4Wh6fK5onmV1xubrsetkfxScPnQL8MtpquREatdTwbjb+m5z/6/8dy0evD\r
+       KuyeC8WWf1th+HRnY8kXtcKnAhOslViKMxINtZiLihMBGXa/PiIDAAA=\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 31 Jan 2012 04:51:15 -0000\r
+\r
+Quoth Mark Walters on Jan 29 at  6:39 pm:\r
+> Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to\r
+> notmuch_query_search_threads. Implemented by inspecting the tags\r
+> directly in _notmuch_thread_create/_thread_add_message rather than as\r
+> a Xapian query for speed reasons.\r
+> ---\r
+>  lib/notmuch-private.h |   16 ++++++++++------\r
+>  lib/query.cc          |    1 +\r
+>  lib/thread.cc         |   18 +++++++++++++++---\r
+>  3 files changed, 26 insertions(+), 9 deletions(-)\r
+> \r
+> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
+> index e791bb0..56b87c6 100644\r
+> --- a/lib/notmuch-private.h\r
+> +++ b/lib/notmuch-private.h\r
+> @@ -211,12 +211,8 @@ _notmuch_directory_get_document_id (notmuch_directory_t *directory);\r
+>  \r
+>  /* thread.cc */\r
+>  \r
+> -notmuch_thread_t *\r
+> -_notmuch_thread_create (void *ctx,\r
+> -                    notmuch_database_t *notmuch,\r
+> -                    unsigned int seed_doc_id,\r
+> -                    notmuch_doc_id_set_t *match_set,\r
+> -                    notmuch_sort_t sort);\r
+> +/* Definition of _notmuch_thread_create moved later since now uses\r
+> + * string_list_t */\r
+\r
+Naw, leave the definition here along with the other things from\r
+thread.cc and just add a\r
+\r
+  typedef struct _notmuch_string_list notmuch_string_list_t;\r
+\r
+along with the typedef for notmuch_doc_id_set_t near the top.  (You\r
+might also have to tweak the typedef of notmuch_string_list_t later so\r
+it's just the struct definition.)\r
+\r
+>  \r
+>  /* message.cc */\r
+>  \r
+> @@ -492,6 +488,14 @@ notmuch_filenames_t *\r
+>  _notmuch_filenames_create (const void *ctx,\r
+>                         notmuch_string_list_t *list);\r
+>  \r
+> +notmuch_thread_t *\r
+> +_notmuch_thread_create (void *ctx,\r
+> +                    notmuch_database_t *notmuch,\r
+> +                    unsigned int seed_doc_id,\r
+> +                    notmuch_doc_id_set_t *match_set,\r
+> +                    notmuch_string_list_t *excluded_terms,\r
+> +                    notmuch_sort_t sort);\r
+> +\r
+>  #pragma GCC visibility pop\r
+>  \r
+>  NOTMUCH_END_DECLS\r
+> diff --git a/lib/query.cc b/lib/query.cc\r
+> index 7d165d2..dee7ec0 100644\r
+> --- a/lib/query.cc\r
+> +++ b/lib/query.cc\r
+> @@ -472,6 +472,7 @@ notmuch_threads_get (notmuch_threads_t *threads)\r
+>                                 threads->query->notmuch,\r
+>                                 doc_id,\r
+>                                 &threads->match_set,\r
+> +                               threads->query->exclude_terms,\r
+>                                 threads->query->sort);\r
+>  }\r
+>  \r
+> diff --git a/lib/thread.cc b/lib/thread.cc\r
+> index 0435ee6..6d65d52 100644\r
+> --- a/lib/thread.cc\r
+> +++ b/lib/thread.cc\r
+> @@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,\r
+>   */\r
+>  static void\r
+>  _thread_add_message (notmuch_thread_t *thread,\r
+> -                 notmuch_message_t *message)\r
+> +                 notmuch_message_t *message,\r
+> +                 notmuch_string_list_t *exclude_terms)\r
+>  {\r
+>      notmuch_tags_t *tags;\r
+>      const char *tag;\r
+> @@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,\r
+>       notmuch_tags_move_to_next (tags))\r
+>      {\r
+>      tag = notmuch_tags_get (tags);\r
+> +    /* mark excluded messages */\r
+\r
+Capital and period.\r
+\r
+> +    for (notmuch_string_node_t *term = exclude_terms->head; term;\r
+> +         term = term->next) {\r
+> +        /* we ignore initial 'K' */\r
+\r
+Same.\r
+\r
+> +        if (strcmp(tag, (term->string + 1)) == 0) {\r
+> +            notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);\r
+> +            break;\r
+> +        }\r
+> +    }\r
+>      g_hash_table_insert (thread->tags, xstrdup (tag), NULL);\r
+>      }\r
+>  }\r
+> @@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,\r
+>          _thread_set_subject_from_message (thread, message);\r
+>      }\r
+>  \r
+> -    thread->matched_messages++;\r
+> +    if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))\r
+> +    thread->matched_messages++;\r
+\r
+I'd still say this warrants a better API.\r
+\r
+>  \r
+>      if (g_hash_table_lookup_extended (thread->message_hash,\r
+>                          notmuch_message_get_message_id (message), NULL,\r
+> @@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,\r
+>                      notmuch_database_t *notmuch,\r
+>                      unsigned int seed_doc_id,\r
+>                      notmuch_doc_id_set_t *match_set,\r
+> +                    notmuch_string_list_t *exclude_terms,\r
+>                      notmuch_sort_t sort)\r
+>  {\r
+>      notmuch_thread_t *thread;\r
+> @@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,\r
+>      if (doc_id == seed_doc_id)\r
+>          message = seed_message;\r
+>  \r
+> -    _thread_add_message (thread, message);\r
+> +    _thread_add_message (thread, message, exclude_terms);\r
+>  \r
+>      if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {\r
+>          _notmuch_doc_id_set_remove (match_set, doc_id);\r