1 Return-Path: <dkg@fifthhorseman.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 2B7166DE028C
\r
6 for <notmuch@notmuchmail.org>; Fri, 8 Apr 2016 18:02:47 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id GiAuDJqU5Egu for <notmuch@notmuchmail.org>;
\r
16 Fri, 8 Apr 2016 18:02:38 -0700 (PDT)
\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])
\r
18 by arlo.cworth.org (Postfix) with ESMTP id C284E6DE0173
\r
19 for <notmuch@notmuchmail.org>; Fri, 8 Apr 2016 18:02:38 -0700 (PDT)
\r
20 Received: from fifthhorseman.net (unknown [201.140.212.132])
\r
21 by che.mayfirst.org (Postfix) with ESMTPSA id 916A910081
\r
22 for <notmuch@notmuchmail.org>; Fri, 8 Apr 2016 21:02:36 -0400 (EDT)
\r
23 Received: by fifthhorseman.net (Postfix, from userid 1000)
\r
24 id 02D73200A4; Fri, 8 Apr 2016 22:02:35 -0300 (ART)
\r
25 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
\r
26 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
27 Subject: [PATCH v3 4/7] Add internal functions to search for alternate doc
\r
29 Date: Fri, 8 Apr 2016 22:02:31 -0300
\r
30 Message-Id: <1460163754-22994-4-git-send-email-dkg@fifthhorseman.net>
\r
31 X-Mailer: git-send-email 2.8.0.rc3
\r
32 In-Reply-To: <1460163754-22994-1-git-send-email-dkg@fifthhorseman.net>
\r
33 References: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net>
\r
34 <1460163754-22994-1-git-send-email-dkg@fifthhorseman.net>
\r
35 X-BeenThere: notmuch@notmuchmail.org
\r
36 X-Mailman-Version: 2.1.20
\r
38 List-Id: "Use and development of the notmuch mail system."
\r
39 <notmuch.notmuchmail.org>
\r
40 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
43 List-Post: <mailto:notmuch@notmuchmail.org>
\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
45 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
47 X-List-Received-Date: Sat, 09 Apr 2016 01:02:47 -0000
\r
49 Publicly we are only exposing the non-ghost documents (of "type"
\r
50 "mail"). But internally we might want to inspect the ghost messages
\r
53 This changeset adds two new private interfaces to queries to recover
\r
54 information about alternate document types.
\r
56 lib/notmuch-private.h | 11 +++++++++++
\r
57 lib/query.cc | 18 ++++++++++++++++--
\r
58 2 files changed, 27 insertions(+), 2 deletions(-)
\r
60 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
\r
61 index 5dd4770..d95bf31 100644
\r
62 --- a/lib/notmuch-private.h
\r
63 +++ b/lib/notmuch-private.h
\r
64 @@ -477,6 +477,17 @@ void
\r
65 _notmuch_doc_id_set_remove (notmuch_doc_id_set_t *doc_ids,
\r
66 unsigned int doc_id);
\r
68 +/* querying xapian documents by type (e.g. "mail" or "ghost"): */
\r
70 +_notmuch_query_search_documents (notmuch_query_t *query,
\r
72 + notmuch_messages_t **out);
\r
75 +_notmuch_query_count_documents (notmuch_query_t *query,
\r
77 + unsigned *count_out);
\r
82 diff --git a/lib/query.cc b/lib/query.cc
\r
83 index e627bfc..77a7926 100644
\r
86 @@ -187,6 +187,14 @@ notmuch_status_t
\r
87 notmuch_query_search_messages_st (notmuch_query_t *query,
\r
88 notmuch_messages_t **out)
\r
90 + return _notmuch_query_search_documents (query, "mail", out);
\r
94 +_notmuch_query_search_documents (notmuch_query_t *query,
\r
96 + notmuch_messages_t **out)
\r
98 notmuch_database_t *notmuch = query->notmuch;
\r
99 const char *query_string = query->query_string;
\r
100 notmuch_mset_messages_t *messages;
\r
101 @@ -208,7 +216,7 @@ notmuch_query_search_messages_st (notmuch_query_t *query,
\r
102 Xapian::Enquire enquire (*notmuch->xapian_db);
\r
103 Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
\r
104 _find_prefix ("type"),
\r
107 Xapian::Query string_query, final_query, exclude_query;
\r
109 Xapian::MSetIterator iterator;
\r
110 @@ -554,6 +562,12 @@ notmuch_query_count_messages (notmuch_query_t *query)
\r
112 notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)
\r
114 + return _notmuch_query_count_documents (query, "mail", count_out);
\r
118 +_notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsigned *count_out)
\r
120 notmuch_database_t *notmuch = query->notmuch;
\r
121 const char *query_string = query->query_string;
\r
122 Xapian::doccount count = 0;
\r
123 @@ -562,7 +576,7 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out)
\r
124 Xapian::Enquire enquire (*notmuch->xapian_db);
\r
125 Xapian::Query mail_query (talloc_asprintf (query, "%s%s",
\r
126 _find_prefix ("type"),
\r
129 Xapian::Query string_query, final_query, exclude_query;
\r
131 unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
\r