Re: Hi all
[notmuch-archives.git] / 4e / d000729258c176613aa12c4f8f8148c8309f44
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 D62B1431FCB\r
6         for <notmuch@notmuchmail.org>; Sat,  3 Mar 2012 05:04:21 -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 t8ok-2zr01Md for <notmuch@notmuchmail.org>;\r
18         Sat,  3 Mar 2012 05:04:21 -0800 (PST)\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
20         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id E6A0A431FAF\r
23         for <notmuch@notmuchmail.org>; Sat,  3 Mar 2012 05:04:20 -0800 (PST)\r
24 Received: by werm13 with SMTP id m13so1818868wer.26\r
25         for <notmuch@notmuchmail.org>; Sat, 03 Mar 2012 05:04:18 -0800 (PST)\r
26 Received-SPF: pass (google.com: domain of markwalters1009@gmail.com designates\r
27         10.180.80.8 as permitted sender) client-ip=10.180.80.8; \r
28 Authentication-Results: mr.google.com; spf=pass (google.com: domain of\r
29         markwalters1009@gmail.com designates 10.180.80.8 as permitted\r
30         sender) smtp.mail=markwalters1009@gmail.com;\r
31         dkim=pass header.i=markwalters1009@gmail.com\r
32 Received: from mr.google.com ([10.180.80.8])\r
33         by 10.180.80.8 with SMTP id n8mr3874977wix.14.1330779858467 (num_hops =\r
34         1); Sat, 03 Mar 2012 05:04:18 -0800 (PST)\r
35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
36         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
37         bh=pBanLPgoew9T56Rshbn7yisqEeJD6pl1qy4lY3OT1J8=;\r
38         b=G2ES9SS9QrMauUekNr/afrQCSziKXCWyRg/WqW5pAG4JEzaUa7I//cEiRq3KGyZrpr\r
39         D0L6TbxwptZ1C3YWnVQ6qUUNJYsL6Z56S3NrPiv6UMeZaCQO+JOsTQpWrkrpTZvH0iEM\r
40         Cdb863g67lQkzPJJXUjx1irvWCLvue+SpkqonmCsfzaDlhBDbJBtPhUYywul0LNCW5Jo\r
41         qBkpChAEADX7d9QUrmkyNo5r0ASWp86D8Bl8+2T0TNSN99LMX6Rqth1b+gqxH5yrwvEi\r
42         BPju1U3vT71GgKgGgMaHHS60z4Sllb+nLYTLOF9u4IZGSerXrmX3Rk/iDGHPMsRwGBJJ\r
43         2Ucg==\r
44 Received: by 10.180.80.8 with SMTP id n8mr3071358wix.14.1330779858430;\r
45         Sat, 03 Mar 2012 05:04:18 -0800 (PST)\r
46 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
47  [94.192.233.223])      by mx.google.com with ESMTPS id\r
48  er8sm27136271wib.1.2012.03.03.05.04.17 (version=TLSv1/SSLv3 cipher=OTHER);\r
49         Sat, 03 Mar 2012 05:04:17 -0800 (PST)\r
50 From: Mark Walters <markwalters1009@gmail.com>\r
51 To: notmuch@notmuchmail.org\r
52 Subject: [PATCH 4/5] cli: move show to the new --with-excluded naming scheme.\r
53 Date: Sat,  3 Mar 2012 13:05:17 +0000\r
54 Message-Id: <1330779918-28024-5-git-send-email-markwalters1009@gmail.com>\r
55 X-Mailer: git-send-email 1.7.2.3\r
56 In-Reply-To: <1330779918-28024-1-git-send-email-markwalters1009@gmail.com>\r
57 References: <1330779918-28024-1-git-send-email-markwalters1009@gmail.com>\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Sat, 03 Mar 2012 13:04:22 -0000\r
71 \r
72 This moves show to the --with-excluded naming scheme. When this is set\r
73 show returns all threads that match including those that only match in\r
74 an excluded message.\r
75 \r
76 When this flag is not set the behaviour depends on whether\r
77 --entire-threads is set. If it is not set then show only returns the\r
78 messages which match and are not excluded. If it is set then show\r
79 returns all messages in these threads.\r
80 ---\r
81  man/man1/notmuch-show.1 |    5 +++--\r
82  notmuch-client.h        |    1 +\r
83  notmuch-show.c          |   38 +++++++++++++++++++++-----------------\r
84  3 files changed, 25 insertions(+), 19 deletions(-)\r
85 \r
86 diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1\r
87 index d75d971..0047298 100644\r
88 --- a/man/man1/notmuch-show.1\r
89 +++ b/man/man1/notmuch-show.1\r
90 @@ -130,9 +130,10 @@ content.\r
91  \r
92  .RS 4\r
93  .TP 4\r
94 -.B \-\-no-exclude\r
95 +.B \-\-with-excluded\r
96  \r
97 -Do not exclude the messages matching search.exclude_tags in the config file.\r
98 +Include threads that only match in excluded messages (from\r
99 +search.exclude_tags in the config file) in the output.\r
100  .RE\r
101  \r
102  A common use of\r
103 diff --git a/notmuch-client.h b/notmuch-client.h\r
104 index f4a62cc..4d9464c 100644\r
105 --- a/notmuch-client.h\r
106 +++ b/notmuch-client.h\r
107 @@ -99,6 +99,7 @@ typedef struct notmuch_show_format {\r
108  \r
109  typedef struct notmuch_show_params {\r
110      notmuch_bool_t entire_thread;\r
111 +    notmuch_bool_t with_excluded;\r
112      notmuch_bool_t raw;\r
113      int part;\r
114  #ifdef GMIME_ATLEAST_26\r
115 diff --git a/notmuch-show.c b/notmuch-show.c\r
116 index 05d51b2..f3440ae 100644\r
117 --- a/notmuch-show.c\r
118 +++ b/notmuch-show.c\r
119 @@ -812,6 +812,7 @@ show_messages (void *ctx,\r
120  {\r
121      notmuch_message_t *message;\r
122      notmuch_bool_t match;\r
123 +    notmuch_bool_t excluded;\r
124      int first_set = 1;\r
125      int next_indent;\r
126  \r
127 @@ -830,10 +831,11 @@ show_messages (void *ctx,\r
128         message = notmuch_messages_get (messages);\r
129  \r
130         match = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH);\r
131 +       excluded = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED);\r
132  \r
133         next_indent = indent;\r
134  \r
135 -       if (match || params->entire_thread) {\r
136 +       if ((match && (!excluded || params->with_excluded)) || params->entire_thread) {\r
137             show_message (ctx, format, message, indent, params);\r
138             next_indent = indent + 1;\r
139  \r
140 @@ -986,7 +988,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
141      notmuch_show_params_t params = { .part = -1 };\r
142      int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
143      notmuch_bool_t verify = FALSE;\r
144 -    notmuch_bool_t no_exclude = FALSE;\r
145 +    notmuch_bool_t with_excluded = FALSE;\r
146  \r
147      notmuch_opt_desc_t options[] = {\r
148         { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
149 @@ -999,7 +1001,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
150         { NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },\r
151         { NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },\r
152         { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },\r
153 -       { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 },\r
154 +       { NOTMUCH_OPT_BOOLEAN, &with_excluded, "with-excluded", 'n', 0 },\r
155         { 0, 0, 0, 0, 0 }\r
156      };\r
157  \r
158 @@ -1088,25 +1090,27 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
159         return 1;\r
160      }\r
161  \r
162 -    /* if format=mbox then we can not output excluded messages as\r
163 -     * there is no way to make the exclude flag available */\r
164 -    if (format_sel == NOTMUCH_FORMAT_MBOX)\r
165 -       notmuch_query_set_omit_excluded_messages (query, TRUE);\r
166 -\r
167      /* If a single message is requested we do not use search_excludes. */\r
168      if (params.part >= 0)\r
169         ret = do_show_single (ctx, query, format, &params);\r
170      else {\r
171 -       if (!no_exclude) {\r
172 -           const char **search_exclude_tags;\r
173 -           size_t search_exclude_tags_length;\r
174 -           unsigned int i;\r
175 -\r
176 -           search_exclude_tags = notmuch_config_get_search_exclude_tags\r
177 -               (config, &search_exclude_tags_length);\r
178 -           for (i = 0; i < search_exclude_tags_length; i++)\r
179 -               notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
180 +       /* We always set the exclude tags: in the case --with-excluded\r
181 +        * we apply notmuch_query_set_with_excluded to the query to\r
182 +        * get all the results (but they will still be marked\r
183 +        * excluded */\r
184 +       const char **search_exclude_tags;\r
185 +       size_t search_exclude_tags_length;\r
186 +       unsigned int i;\r
187 +\r
188 +       search_exclude_tags = notmuch_config_get_search_exclude_tags\r
189 +           (config, &search_exclude_tags_length);\r
190 +       for (i = 0; i < search_exclude_tags_length; i++)\r
191 +           notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
192 +       if (with_excluded) {\r
193 +           notmuch_query_set_with_excluded_messages(query, TRUE);\r
194 +           params.with_excluded = TRUE;\r
195         }\r
196 +\r
197         ret = do_show (ctx, query, format, &params);\r
198      }\r
199  \r
200 -- \r
201 1.7.2.3\r
202 \r