[PATCH v4 01/11] cli: add --no-exclude option to count and search.
[notmuch-archives.git] / ea / 7a99c87da8bfc4325811b7a7150968502cdd9a
1 Return-Path: <markwalters1009@gmail.com>\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 8A6EF431FBD\r
6         for <notmuch@notmuchmail.org>; Thu,  2 Feb 2012 09:42:46 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id VVRxbiX0TIi3 for <notmuch@notmuchmail.org>;\r
18         Thu,  2 Feb 2012 09:42:46 -0800 (PST)\r
19 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
20  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  B1F02431FAE    for <notmuch@notmuchmail.org>; Thu,  2 Feb 2012 09:42:45 -0800\r
23  (PST)\r
24 Received: by wgbdt12 with SMTP id dt12so2522817wgb.2\r
25         for <notmuch@notmuchmail.org>; Thu, 02 Feb 2012 09:42:44 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=emWAclt80HEiOKvc49r6U+LEsYM7rTnjWaIKwiSuCgM=;\r
29         b=vx/N6Qks+fZizZWnI03jARbSrQRRYkylx4oW4XOeEuaihiFA3fBrkepBtP5X5Cf1gy\r
30         m5Gq3X9ShNYQes0On+SiKFPbWTemtEVfuvuVGBDtKw/r2nvC30Rb4JyU47A24XqQZuc6\r
31         9AqSy5t7BT6nPWfGxBIAr3T+dWYwjE0hMCz34=\r
32 Received: by 10.180.97.166 with SMTP id eb6mr6269108wib.5.1328204564171;\r
33         Thu, 02 Feb 2012 09:42:44 -0800 (PST)\r
34 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
35  [94.192.233.223])      by mx.google.com with ESMTPS id\r
36  l6sm1098442wiv.11.2012.02.02.09.42.42  (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Thu, 02 Feb 2012 09:42:43 -0800 (PST)\r
38 From: Mark Walters <markwalters1009@gmail.com>\r
39 To: notmuch@notmuchmail.org,\r
40         amdragon@MIT.EDU\r
41 Subject: [PATCH v4 01/11] cli: add --no-exclude option to count and search.\r
42 Date: Thu,  2 Feb 2012 17:43:29 +0000\r
43 Message-Id: <1328204619-25046-1-git-send-email-markwalters1009@gmail.com>\r
44 X-Mailer: git-send-email 1.7.2.3\r
45 In-Reply-To: <874nv9rv79.fsf@qmul.ac.uk>\r
46 References: <874nv9rv79.fsf@qmul.ac.uk>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Thu, 02 Feb 2012 17:42:46 -0000\r
60 \r
61 This option turns off the exclusion so all matching messages are\r
62 returned. We do not need to add this to notmuch-show as that does not\r
63 (yet) exclude.\r
64 ---\r
65  notmuch-count.c  |   17 +++++++++++------\r
66  notmuch-search.c |   17 +++++++++++------\r
67  2 files changed, 22 insertions(+), 12 deletions(-)\r
68 \r
69 diff --git a/notmuch-count.c b/notmuch-count.c\r
70 index 63459fb..5364507 100644\r
71 --- a/notmuch-count.c\r
72 +++ b/notmuch-count.c\r
73 @@ -35,8 +35,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
74      char *query_str;\r
75      int opt_index;\r
76      int output = OUTPUT_MESSAGES;\r
77 -    const char **search_exclude_tags;\r
78 -    size_t search_exclude_tags_length;\r
79 +    notmuch_bool_t no_exclude = FALSE;\r
80      unsigned int i;\r
81  \r
82      notmuch_opt_desc_t options[] = {\r
83 @@ -44,6 +43,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
84           (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },\r
85                                   { "messages", OUTPUT_MESSAGES },\r
86                                   { 0, 0 } } },\r
87 +       { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },\r
88         { 0, 0, 0, 0, 0 }\r
89      };\r
90  \r
91 @@ -78,10 +78,15 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
92         return 1;\r
93      }\r
94  \r
95 -    search_exclude_tags = notmuch_config_get_search_exclude_tags\r
96 -       (config, &search_exclude_tags_length);\r
97 -    for (i = 0; i < search_exclude_tags_length; i++)\r
98 -       notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
99 +    if (!no_exclude) {\r
100 +       const char **search_exclude_tags;\r
101 +       size_t search_exclude_tags_length;\r
102 +\r
103 +       search_exclude_tags = notmuch_config_get_search_exclude_tags\r
104 +           (config, &search_exclude_tags_length);\r
105 +       for (i = 0; i < search_exclude_tags_length; i++)\r
106 +           notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
107 +    }\r
108  \r
109      switch (output) {\r
110      case OUTPUT_MESSAGES:\r
111 diff --git a/notmuch-search.c b/notmuch-search.c\r
112 index d504051..43ec90b 100644\r
113 --- a/notmuch-search.c\r
114 +++ b/notmuch-search.c\r
115 @@ -423,8 +423,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
116      output_t output = OUTPUT_SUMMARY;\r
117      int offset = 0;\r
118      int limit = -1; /* unlimited */\r
119 -    const char **search_exclude_tags;\r
120 -    size_t search_exclude_tags_length;\r
121 +    notmuch_bool_t no_exclude = FALSE;\r
122      unsigned int i;\r
123  \r
124      enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }\r
125 @@ -446,6 +445,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
126                                   { "files", OUTPUT_FILES },\r
127                                   { "tags", OUTPUT_TAGS },\r
128                                   { 0, 0 } } },\r
129 +        { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },\r
130         { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
131         { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },\r
132         { 0, 0, 0, 0, 0 }\r
133 @@ -493,10 +493,15 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
134  \r
135      notmuch_query_set_sort (query, sort);\r
136  \r
137 -    search_exclude_tags = notmuch_config_get_search_exclude_tags\r
138 -       (config, &search_exclude_tags_length);\r
139 -    for (i = 0; i < search_exclude_tags_length; i++)\r
140 -       notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
141 +    if (!no_exclude) {\r
142 +       const char **search_exclude_tags;\r
143 +       size_t search_exclude_tags_length;\r
144 +\r
145 +       search_exclude_tags = notmuch_config_get_search_exclude_tags\r
146 +           (config, &search_exclude_tags_length);\r
147 +       for (i = 0; i < search_exclude_tags_length; i++)\r
148 +           notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
149 +    }\r
150  \r
151      switch (output) {\r
152      default:\r
153 -- \r
154 1.7.2.3\r
155 \r