[PATCH 6/9] CLI: refactor dumping of tags.
[notmuch-archives.git] / ca / 99ca6ccc2a9586074aceb1550fe12388381ee9
1 Return-Path: <david@tethera.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 olra.theworths.org (Postfix) with ESMTP id 1B688431E62\r
6         for <notmuch@notmuchmail.org>; Sun,  7 Dec 2014 03:52:57 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id pIioDdv0oraY for <notmuch@notmuchmail.org>;\r
16         Sun,  7 Dec 2014 03:52:53 -0800 (PST)\r
17 Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
18         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id DE817431FDF\r
21         for <notmuch@notmuchmail.org>; Sun,  7 Dec 2014 03:52:53 -0800 (PST)\r
22 Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
23         (envelope-from <david@tethera.net>)\r
24         id 1XxaOP-0001m2-2n; Sun, 07 Dec 2014 07:52:49 -0400\r
25 Received: (nullmailer pid 26232 invoked by uid 1000); Sun, 07 Dec 2014\r
26         11:52:43 -0000\r
27 From: David Bremner <david@tethera.net>\r
28 To: Gaute Hope <eg@gaute.vetsj.com>, notmuch@notmuchmail.org\r
29 Subject: Re: notmuch_query_add_tag_excluded and notmuch_query_search_threads\r
30 In-Reply-To: <1417905319-astroid-0-i86er7iwg5-10728@strange>\r
31 References: <1417905319-astroid-0-i86er7iwg5-10728@strange>\r
32 User-Agent: Notmuch/0.19+2~g32855b9 (http://notmuchmail.org) Emacs/24.4.1\r
33         (x86_64-pc-linux-gnu)\r
34 Date: Sun, 07 Dec 2014 12:52:43 +0100\r
35 Message-ID: <87388rfzhw.fsf@maritornes.cs.unb.ca>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Sun, 07 Dec 2014 11:52:57 -0000\r
51 \r
52 Gaute Hope <eg@gaute.vetsj.com> writes:\r
53 \r
54 >\r
55 > I would expect to have the thread matching, I get nothing however. It\r
56 > does show up in: $ notmuch search tag:muted (muted added to excluded\r
57 > tags), but does notmuch search operate with\r
58 > notmuch_query_search_messages? \r
59 >\r
60 \r
61 I expanded your sample into a full program, and it seems to work ok for\r
62 me. Not sure what the difference might be.\r
63 \r
64 #include <notmuch.h>\r
65 #include <stdlib.h>\r
66 #include <stdio.h>\r
67 int main(int argc, char **argv){\r
68 \r
69   notmuch_database_t *nm_db;\r
70   notmuch_query_t *query;\r
71   notmuch_threads_t *threads;\r
72   notmuch_thread_t *thread;\r
73 \r
74   if (notmuch_database_open ("/home/bremner/Maildir/",\r
75                              NOTMUCH_DATABASE_MODE_READ_ONLY, &nm_db))\r
76     return 1;\r
77 \r
78 \r
79   \r
80   query = notmuch_query_create (nm_db, "tag:muted");\r
81   notmuch_query_add_tag_exclude (query, "muted");\r
82   notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_TRUE);\r
83 \r
84   for (threads = notmuch_query_search_threads (query);\r
85        notmuch_threads_valid (threads);\r
86        notmuch_threads_move_to_next (threads))\r
87     {\r
88       thread = notmuch_threads_get (threads);\r
89       printf("%d\n", notmuch_thread_get_total_messages(thread));\r
90       notmuch_thread_destroy (thread);\r
91     }\r
92 \r
93 }\r
94 \r