Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 10 / 9537d0f2a9c2e499294a15e0ced3552d694113
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 32DE5431FD6\r
6         for <notmuch@notmuchmail.org>; Fri,  6 Apr 2012 05:49:28 -0700 (PDT)\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 zFSzabWV9VZt for <notmuch@notmuchmail.org>;\r
18         Fri,  6 Apr 2012 05:49:26 -0700 (PDT)\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 2B890429E2E\r
23         for <notmuch@notmuchmail.org>; Fri,  6 Apr 2012 05:49:24 -0700 (PDT)\r
24 Received: by mail-we0-f181.google.com with SMTP id m13so1667174wer.26\r
25         for <notmuch@notmuchmail.org>; Fri, 06 Apr 2012 05:49:23 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=sJInaK4MPwl719u/pQeaJN1jaTkMGa+HjYOfWYMFtaA=;\r
29         b=GcVjyXtwbYLKIF0OA146At1lmwEZy6uAKP3r9em88T1hMm60yE7Asc4qe4WvM4kifS\r
30         wxHKHiDWmwoTENKT2HEynJ7iI4Hrw9P4SA6C6RRJId2mCBoqdwylEWaeR2YLXN6UWcOy\r
31         tDhfMUODzYxDRuEyAa8ubk88J2JRlruK341B7xZVsoD5jfX4Wgms2sg2AzAP3AX1i/zb\r
32         sruu9HObaKb20HToq1rkNdEKNYzXd++hw1DBy2Zv8zx8az0gOtuf7XSx1VYQeobPAtdU\r
33         tmg0yTY22AW1A5Sa1UCMf6gYTiMYy1UxKEmJvoqYSFp1hwuBNeVj5Jh86cbhSPFeVLJK\r
34         2mGw==\r
35 Received: by 10.216.137.226 with SMTP id y76mr3620144wei.96.1333716563813;\r
36         Fri, 06 Apr 2012 05:49:23 -0700 (PDT)\r
37 Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
38  [94.192.233.223])      by mx.google.com with ESMTPS id\r
39  e6sm6141546wix.8.2012.04.06.05.49.22   (version=TLSv1/SSLv3 cipher=OTHER);     Fri,\r
40  06 Apr 2012 05:49:22 -0700 (PDT)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v3 5/6] cli: move show to the new --exclude= option naming\r
44         scheme.\r
45 Date: Fri,  6 Apr 2012 13:49:10 +0100\r
46 Message-Id: <1333716551-29153-6-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.9.1\r
48 In-Reply-To: <1333716551-29153-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1333716551-29153-1-git-send-email-markwalters1009@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Fri, 06 Apr 2012 12:49:28 -0000\r
63 \r
64 This moves notmuch show to the --exclude=(true|false) naming\r
65 scheme. When exclude=false show returns all threads that match\r
66 including those that only match in an excluded message. The excluded\r
67 messages are flagged.\r
68 \r
69 When exclude=true the behaviour depends on whether --entire-thread is\r
70 set. If it is not set then show only returns the messages which match\r
71 and are not excluded. If it is set then show returns all messages in\r
72 the threads that match in a non-excluded message, flagging the excluded\r
73 messages in these threads. The rationale is that it is awkward to use\r
74 a thread with some missing messages.\r
75 ---\r
76  man/man1/notmuch-show.1 |   16 +++++++++++++-\r
77  notmuch-client.h        |    1 +\r
78  notmuch-show.c          |   50 +++++++++++++++++++++++++++++-----------------\r
79  3 files changed, 46 insertions(+), 21 deletions(-)\r
80 \r
81 diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1\r
82 index b81cce6..83cc575 100644\r
83 --- a/man/man1/notmuch-show.1\r
84 +++ b/man/man1/notmuch-show.1\r
85 @@ -135,9 +135,21 @@ content.\r
86  \r
87  .RS 4\r
88  .TP 4\r
89 -.B \-\-no-exclude\r
90 +.BR \-\-exclude=(true|false)\r
91 +\r
92 +Specify whether to omit threads only matching search.tag_exclude from\r
93 +the search results (the default) or not. In either case the excluded\r
94 +message will be marked with the exclude flag (except when output=mbox\r
95 +when there is nowhere to put the flag).\r
96 +\r
97 +If --entire-thread is specified then complete threads are returned\r
98 +regardless (with the excluded flag being set when appropriate) but\r
99 +threads that only match in an excluded message are not returned when\r
100 +.B --exclude=true.\r
101 +\r
102 +The default is\r
103 +.B --exclude=true.\r
104  \r
105 -Do not exclude the messages matching search.exclude_tags in the config file.\r
106  .RE\r
107  \r
108  A common use of\r
109 diff --git a/notmuch-client.h b/notmuch-client.h\r
110 index 203ac49..880b153 100644\r
111 --- a/notmuch-client.h\r
112 +++ b/notmuch-client.h\r
113 @@ -99,6 +99,7 @@ typedef struct notmuch_show_format {\r
114  \r
115  typedef struct notmuch_show_params {\r
116      notmuch_bool_t entire_thread;\r
117 +    notmuch_bool_t omit_excluded;\r
118      notmuch_bool_t raw;\r
119      int part;\r
120  #ifdef GMIME_ATLEAST_26\r
121 diff --git a/notmuch-show.c b/notmuch-show.c\r
122 index 0bf5e21..7af8e64 100644\r
123 --- a/notmuch-show.c\r
124 +++ b/notmuch-show.c\r
125 @@ -866,6 +866,7 @@ show_messages (void *ctx,\r
126  {\r
127      notmuch_message_t *message;\r
128      notmuch_bool_t match;\r
129 +    notmuch_bool_t excluded;\r
130      int first_set = 1;\r
131      int next_indent;\r
132      notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;\r
133 @@ -885,10 +886,11 @@ show_messages (void *ctx,\r
134         message = notmuch_messages_get (messages);\r
135  \r
136         match = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH);\r
137 +       excluded = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED);\r
138  \r
139         next_indent = indent;\r
140  \r
141 -       if (match || params->entire_thread) {\r
142 +       if ((match && (!excluded || !params->omit_excluded)) || params->entire_thread) {\r
143             status = show_message (ctx, format, message, indent, params);\r
144             if (status && !res)\r
145                 res = status;\r
146 @@ -996,6 +998,12 @@ enum {\r
147      NOTMUCH_FORMAT_RAW\r
148  };\r
149  \r
150 +/* The following is to allow future options to be added more easily */\r
151 +enum {\r
152 +    EXCLUDE_TRUE,\r
153 +    EXCLUDE_FALSE,\r
154 +};\r
155 +\r
156  int\r
157  notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
158  {\r
159 @@ -1005,10 +1013,10 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
160      char *query_string;\r
161      int opt_index, ret;\r
162      const notmuch_show_format_t *format = &format_text;\r
163 -    notmuch_show_params_t params = { .part = -1 };\r
164 +    notmuch_show_params_t params = { .part = -1, .omit_excluded = TRUE };\r
165      int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;\r
166      notmuch_bool_t verify = FALSE;\r
167 -    notmuch_bool_t no_exclude = FALSE;\r
168 +    int exclude = EXCLUDE_TRUE;\r
169  \r
170      notmuch_opt_desc_t options[] = {\r
171         { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
172 @@ -1017,11 +1025,14 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
173                                   { "mbox", NOTMUCH_FORMAT_MBOX },\r
174                                   { "raw", NOTMUCH_FORMAT_RAW },\r
175                                   { 0, 0 } } },\r
176 +        { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',\r
177 +          (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
178 +                                  { "false", EXCLUDE_FALSE },\r
179 +                                  { 0, 0 } } },\r
180         { NOTMUCH_OPT_INT, &params.part, "part", 'p', 0 },\r
181         { NOTMUCH_OPT_BOOLEAN, &params.entire_thread, "entire-thread", 't', 0 },\r
182         { NOTMUCH_OPT_BOOLEAN, &params.decrypt, "decrypt", 'd', 0 },\r
183         { NOTMUCH_OPT_BOOLEAN, &verify, "verify", 'v', 0 },\r
184 -       { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'n', 0 },\r
185         { 0, 0, 0, 0, 0 }\r
186      };\r
187  \r
188 @@ -1110,29 +1121,30 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
189         return 1;\r
190      }\r
191  \r
192 -    /* if format=mbox then we can not output excluded messages as\r
193 -     * there is no way to make the exclude flag available */\r
194 -    if (format_sel == NOTMUCH_FORMAT_MBOX)\r
195 -       notmuch_query_set_omit_excluded_messages (query, TRUE);\r
196 -\r
197      /* If a single message is requested we do not use search_excludes. */\r
198      if (params.part >= 0)\r
199         ret = do_show_single (ctx, query, format, &params);\r
200      else {\r
201 -       if (!no_exclude) {\r
202 -           const char **search_exclude_tags;\r
203 -           size_t search_exclude_tags_length;\r
204 -           unsigned int i;\r
205 -\r
206 -           search_exclude_tags = notmuch_config_get_search_exclude_tags\r
207 -               (config, &search_exclude_tags_length);\r
208 -           for (i = 0; i < search_exclude_tags_length; i++)\r
209 -               notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
210 +       /* We always apply set the exclude flag. The\r
211 +        * exclude=true|false option controls whether or not we return\r
212 +        * threads that only match in an excluded message */\r
213 +       const char **search_exclude_tags;\r
214 +       size_t search_exclude_tags_length;\r
215 +       unsigned int i;\r
216 +\r
217 +       search_exclude_tags = notmuch_config_get_search_exclude_tags\r
218 +           (config, &search_exclude_tags_length);\r
219 +       for (i = 0; i < search_exclude_tags_length; i++)\r
220 +           notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
221 +\r
222 +       if (exclude == EXCLUDE_FALSE) {\r
223 +           notmuch_query_set_omit_excluded (query, FALSE);\r
224 +           params.omit_excluded = FALSE;\r
225         }\r
226 +\r
227         ret = do_show (ctx, query, format, &params);\r
228      }\r
229  \r
230 -\r
231      notmuch_query_destroy (query);\r
232      notmuch_database_close (notmuch);\r
233  \r
234 -- \r
235 1.7.9.1\r
236 \r