Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5a / e22e0e98bd3fe5919bd2346b932daffe91b49f
1 Return-Path: <m.walters@qmul.ac.uk>\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 3DA35431FB6\r
6         for <notmuch@notmuchmail.org>; Mon, 13 May 2013 08:11:08 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 45rUyUlPaHzT for <notmuch@notmuchmail.org>;\r
17         Mon, 13 May 2013 08:11:03 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 4133D431FAE\r
22         for <notmuch@notmuchmail.org>; Mon, 13 May 2013 08:11:03 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1UbuOr-0003Yf-JL; Mon, 13 May 2013 16:10:54 +0100\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1UbuOr-000800-5M; Mon, 13 May 2013 16:10:53 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH v3 7/8] lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t\r
34 In-Reply-To: <1368301809-12532-8-git-send-email-markwalters1009@gmail.com>\r
35 References: <1368301809-12532-1-git-send-email-markwalters1009@gmail.com>\r
36         <1368301809-12532-8-git-send-email-markwalters1009@gmail.com>\r
37 User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1\r
38         (x86_64-pc-linux-gnu)\r
39 Date: Mon, 13 May 2013 16:10:51 +0100\r
40 Message-ID: <87bo8edif8.fsf@qmul.ac.uk>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-Sender-Host-Address: 93.97.24.31\r
44 X-QM-SPAM-Info: Sender has good ham record.  :)\r
45 X-QM-Body-MD5: 1b89b2a8c76183871369839af6322033 (of first 20000 bytes)\r
46 X-SpamAssassin-Score: -0.3\r
47 X-SpamAssassin-SpamBar: /\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
49         determine if it is\r
50         spam. We require at least 5.0 points to mark a message as spam.\r
51         This message scored -0.3 points.\r
52         Summary of the scoring: \r
53         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
54         provider *      (markwalters1009[at]gmail.com)\r
55         * -0.3 AWL AWL: From: address is in the auto white-list\r
56 X-QM-Scan-Virus: ClamAV says the message is clean\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Mon, 13 May 2013 15:11:08 -0000\r
70 \r
71 \r
72 Add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t so that it can\r
73 cover all four values of search --exclude in the cli.\r
74 \r
75 Previously the way to avoid any message being marked excluded was to\r
76 pass in an empty list of excluded tags: since we now have an explicit\r
77 option we might as well honour it.\r
78 \r
79 The enum is in a slightly strange order as the existing FALSE/TRUE\r
80 options correspond to the new\r
81 NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options so this means we do\r
82 not need to bump the version number.\r
83 \r
84 Indeed, an example of this is that the cli count and show still use\r
85 FALSE/TRUE and still work.\r
86 ---\r
87 \r
88 This is a new version of this single patch. In Peter's version\r
89 NOTMUCH_EXCLUDE_FLAG and NOTMUCH_EXCLUDE_FALSE were treated as synonyms:\r
90 this makes them behave in the obvious way and documents them.\r
91 \r
92 I think the only subtlety is the enum order mentioned in the commit\r
93 message. Additionally it would be good to update cli count and show and,\r
94 at for the latter, it would be good to add an option exclude=all too (so\r
95 excluded messages are completely omitted). Those should both be simple\r
96 but we need to decide whether to allow all four options\r
97 (false/flag/true/all) always or not. Always allowing all 4 is nicely\r
98 consistent but sometimes redundant. Additionally we would need some\r
99 tests.\r
100 \r
101 I think this patch should go in with the main series as I think it is\r
102 worth reserving the NOTMUCH_EXCLUDE_FALSE #define/value so that we don't\r
103 break code in future if we do wish to add it.\r
104 \r
105 Best wishes\r
106 \r
107 Mark\r
108 \r
109 \r
110  \r
111  lib/notmuch.h    |   18 ++++++++++++++++--\r
112  lib/query.cc     |    8 +++++---\r
113  lib/thread.cc    |   28 +++++++++++++++-------------\r
114  notmuch-search.c |    2 +-\r
115  4 files changed, 37 insertions(+), 19 deletions(-)\r
116 \r
117 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
118 index 27b43ff..73c85a4 100644\r
119 --- a/lib/notmuch.h\r
120 +++ b/lib/notmuch.h\r
121 @@ -500,10 +500,15 @@ typedef enum {\r
122  const char *\r
123  notmuch_query_get_query_string (notmuch_query_t *query);\r
124  \r
125 -/* Exclude values for notmuch_query_set_omit_excluded */\r
126 +/* Exclude values for notmuch_query_set_omit_excluded. The strange\r
127 + * order is to maintain backward compatibility: the old FALSE/TRUE\r
128 + * options correspond to the new\r
129 + * NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options.\r
130 + */\r
131  typedef enum {\r
132 -    NOTMUCH_EXCLUDE_FALSE,\r
133 +    NOTMUCH_EXCLUDE_FLAG,\r
134      NOTMUCH_EXCLUDE_TRUE,\r
135 +    NOTMUCH_EXCLUDE_FALSE,\r
136      NOTMUCH_EXCLUDE_ALL\r
137  } notmuch_exclude_t;\r
138  \r
139 @@ -517,6 +522,15 @@ typedef enum {\r
140   * match in at least one non-excluded message.  Otherwise, if set to ALL,\r
141   * notmuch_query_search_threads will omit excluded messages from all threads.\r
142   *\r
143 + * If set to FALSE or FLAG then both notmuch_query_search_messages and\r
144 + * notmuch_query_search_threads will return all matching\r
145 + * messages/threads regardless of exclude status. If set to FLAG then\r
146 + * the exclude flag will be set for any excluded message that is\r
147 + * returned by notmuch_query_search_messages, and the thread counts\r
148 + * for threads returned by notmuch_query_search_threads will be the\r
149 + * number of non-excluded messages/matches. Otherwise, if set to\r
150 + * FALSE, then the exclude status is completely ignored.\r
151 + *\r
152   * The performance difference when calling\r
153   * notmuch_query_search_messages should be relatively small (and both\r
154   * should be very fast).  However, in some cases,\r
155 diff --git a/lib/query.cc b/lib/query.cc\r
156 index 1cc768f..69668a4 100644\r
157 --- a/lib/query.cc\r
158 +++ b/lib/query.cc\r
159 @@ -218,13 +218,15 @@ notmuch_query_search_messages (notmuch_query_t *query)\r
160         }\r
161         messages->base.excluded_doc_ids = NULL;\r
162  \r
163 -       if (query->exclude_terms) {\r
164 +       if ((query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) && (query->exclude_terms)) {\r
165             exclude_query = _notmuch_exclude_tags (query, final_query);\r
166  \r
167 -           if (query->omit_excluded != NOTMUCH_EXCLUDE_FALSE)\r
168 +           if (query->omit_excluded == NOTMUCH_EXCLUDE_TRUE ||\r
169 +               query->omit_excluded == NOTMUCH_EXCLUDE_ALL)\r
170 +           {\r
171                 final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,\r
172                                              final_query, exclude_query);\r
173 -           else {\r
174 +           } else { /* NOTMUCH_EXCLUDE_FLAG */\r
175                 exclude_query = Xapian::Query (Xapian::Query::OP_AND,\r
176                                            exclude_query, final_query);\r
177  \r
178 diff --git a/lib/thread.cc b/lib/thread.cc\r
179 index bc07877..4dcf705 100644\r
180 --- a/lib/thread.cc\r
181 +++ b/lib/thread.cc\r
182 @@ -238,20 +238,22 @@ _thread_add_message (notmuch_thread_t *thread,\r
183      char *clean_author;\r
184      notmuch_bool_t message_excluded = FALSE;\r
185  \r
186 -    for (tags = notmuch_message_get_tags (message);\r
187 -        notmuch_tags_valid (tags);\r
188 -        notmuch_tags_move_to_next (tags))\r
189 -    {\r
190 -       tag = notmuch_tags_get (tags);\r
191 -       /* Is message excluded? */\r
192 -       for (notmuch_string_node_t *term = exclude_terms->head;\r
193 -            term != NULL;\r
194 -            term = term->next)\r
195 +    if (omit_exclude != NOTMUCH_EXCLUDE_FALSE) {\r
196 +       for (tags = notmuch_message_get_tags (message);\r
197 +            notmuch_tags_valid (tags);\r
198 +            notmuch_tags_move_to_next (tags))\r
199         {\r
200 -           /* We ignore initial 'K'. */\r
201 -           if (strcmp(tag, (term->string + 1)) == 0) {\r
202 -               message_excluded = TRUE;\r
203 -               break;\r
204 +           tag = notmuch_tags_get (tags);\r
205 +           /* Is message excluded? */\r
206 +           for (notmuch_string_node_t *term = exclude_terms->head;\r
207 +                term != NULL;\r
208 +                term = term->next)\r
209 +           {\r
210 +               /* We ignore initial 'K'. */\r
211 +               if (strcmp(tag, (term->string + 1)) == 0) {\r
212 +                   message_excluded = TRUE;\r
213 +                   break;\r
214 +               }\r
215             }\r
216         }\r
217      }\r
218 diff --git a/notmuch-search.c b/notmuch-search.c\r
219 index 4323201..a20791a 100644\r
220 --- a/notmuch-search.c\r
221 +++ b/notmuch-search.c\r
222 @@ -411,7 +411,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
223         for (i = 0; i < search_exclude_tags_length; i++)\r
224             notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);\r
225         if (exclude == EXCLUDE_FLAG)\r
226 -           notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FALSE);\r
227 +           notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_FLAG);\r
228         if (exclude == EXCLUDE_ALL)\r
229             notmuch_query_set_omit_excluded (query, NOTMUCH_EXCLUDE_ALL);\r
230      }\r
231 -- \r
232 1.7.9.1\r
233 \r