Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5a / bc24fb338d2ac5c2863353e00d51068c4ec2be
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 3A495431FC4\r
6         for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 12:41:03 -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: -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 j0+jkCkpVI2V for <notmuch@notmuchmail.org>;\r
17         Sun, 16 Dec 2012 12:40:59 -0800 (PST)\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 62FB0431FAE\r
22         for <notmuch@notmuchmail.org>; Sun, 16 Dec 2012 12:40:59 -0800 (PST)\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 1TkL13-0005nd-3g; Sun, 16 Dec 2012 20:40:55 +0000\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.69)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1TkL12-0000ip-Ma; Sun, 16 Dec 2012 20:40:52 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
33 Subject: Re: [RFC PATCH] cli: add --remove-all option to "notmuch tag"\r
34 In-Reply-To: <1354572764-28701-1-git-send-email-jani@nikula.org>\r
35 References: <1354572764-28701-1-git-send-email-jani@nikula.org>\r
36 User-Agent: Notmuch/0.14+226~ge56ae2a (http://notmuchmail.org) Emacs/23.4.1\r
37         (x86_64-pc-linux-gnu)\r
38 Date: Sun, 16 Dec 2012 20:40:56 +0000\r
39 Message-ID: <87fw35enmv.fsf@qmul.ac.uk>\r
40 MIME-Version: 1.0\r
41 Content-Type: text/plain; charset=us-ascii\r
42 X-Sender-Host-Address: 93.97.24.31\r
43 X-QM-SPAM-Info: Sender has good ham record.  :)\r
44 X-QM-Body-MD5: d14b80d6c548e91ea60119cb13eefc1e (of first 20000 bytes)\r
45 X-SpamAssassin-Score: -1.8\r
46 X-SpamAssassin-SpamBar: -\r
47 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
48         determine if it is\r
49         spam. We require at least 5.0 points to mark a message as spam.\r
50         This message scored -1.8 points.\r
51         Summary of the scoring: \r
52         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
53         *      medium trust\r
54         *      [138.37.6.40 listed in list.dnswl.org]\r
55         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
56         provider *      (markwalters1009[at]gmail.com)\r
57         *  0.5 AWL AWL: From: address is in the auto white-list\r
58 X-QM-Scan-Virus: ClamAV says the message is clean\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Sun, 16 Dec 2012 20:41:03 -0000\r
72 \r
73 \r
74 On Mon, 03 Dec 2012, Jani Nikula <jani@nikula.org> wrote:\r
75 > Add --remove-all option to "notmuch tag" to remove all tags matching\r
76 > query before applying the tag changes. This allows removal and\r
77 > unconditional setting of the tags of a message:\r
78 >\r
79 > $ notmuch tag --remove-all id:foo@example.com\r
80 > $ notmuch tag --remove-all +foo +bar id:foo@example.com\r
81 >\r
82 > without having to resort to the complicated (and still quoting broken):\r
83 >\r
84 > $ notmuch tag $(notmuch search --output=tags '*' | sed 's/^/-/') id:foo@example.com\r
85 > $ notmuch tag $(notmuch search --output=tags '*' | sed 's/^/-/') +foo +bar id:foo@example.com\r
86 >\r
87 > ---\r
88 >\r
89 > It's completely untested...\r
90 >\r
91 > This is on top of David's batch tagging branch new-tagging at\r
92 > git://pivot.cs.unb.ca/notmuch.git\r
93 >\r
94 > If there's interest, I'll spin a new version with tests and man page\r
95 > changes after David's stuff has been merged.\r
96 \r
97 I like this: the possibility of setting the tags to something seems\r
98 nice. \r
99 \r
100 I am not very keen on the option name but don't have anything much\r
101 better: maybe --remove-all-first or --set-to? \r
102 \r
103 Incidentally, does this (or should this) give an error if the user calls\r
104 --remove-all with -some_tag (as opposed to +some_tag)?\r
105 \r
106 Best wishes\r
107 \r
108 Mark\r
109 \r
110 \r
111 > ---\r
112 >  notmuch-tag.c |   32 ++++++++++++++++++++------------\r
113 >  1 file changed, 20 insertions(+), 12 deletions(-)\r
114 >\r
115 > diff --git a/notmuch-tag.c b/notmuch-tag.c\r
116 > index e4fca67..67624cc 100644\r
117 > --- a/notmuch-tag.c\r
118 > +++ b/notmuch-tag.c\r
119 > @@ -119,12 +119,15 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
120 >      notmuch_messages_t *messages;\r
121 >      notmuch_message_t *message;\r
122 >  \r
123 > -    /* Optimize the query so it excludes messages that already have\r
124 > -     * the specified set of tags. */\r
125 > -    query_string = _optimize_tag_query (ctx, query_string, tag_ops);\r
126 > -    if (query_string == NULL) {\r
127 > -     fprintf (stderr, "Out of memory.\n");\r
128 > -     return 1;\r
129 > +    if (! (flags & TAG_FLAG_REMOVE_ALL)) {\r
130 > +     /* Optimize the query so it excludes messages that already\r
131 > +      * have the specified set of tags. */\r
132 > +     query_string = _optimize_tag_query (ctx, query_string, tag_ops);\r
133 > +     if (query_string == NULL) {\r
134 > +         fprintf (stderr, "Out of memory.\n");\r
135 > +         return 1;\r
136 > +     }\r
137 > +     flags |= TAG_FLAG_PRE_OPTIMIZED;\r
138 >      }\r
139 >  \r
140 >      query = notmuch_query_create (notmuch, query_string);\r
141 > @@ -140,7 +143,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
142 >        notmuch_messages_valid (messages) && ! interrupted;\r
143 >        notmuch_messages_move_to_next (messages)) {\r
144 >       message = notmuch_messages_get (messages);\r
145 > -     tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);\r
146 > +     tag_op_list_apply (message, tag_ops, flags);\r
147 >       notmuch_message_destroy (message);\r
148 >      }\r
149 >  \r
150 > @@ -157,8 +160,9 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
151 >      notmuch_config_t *config;\r
152 >      notmuch_database_t *notmuch;\r
153 >      struct sigaction action;\r
154 > -    tag_op_flag_t synchronize_flags = TAG_FLAG_NONE;\r
155 > +    tag_op_flag_t flags = TAG_FLAG_NONE;\r
156 >      notmuch_bool_t batch = FALSE;\r
157 > +    notmuch_bool_t remove_all = FALSE;\r
158 >      FILE *input = stdin;\r
159 >      char *input_file_name = NULL;\r
160 >      int i, opt_index;\r
161 > @@ -174,6 +178,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
162 >      notmuch_opt_desc_t options[] = {\r
163 >       { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 },\r
164 >       { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },\r
165 > +     { NOTMUCH_OPT_BOOLEAN, &remove_all, "remove-all", 0, 0 },\r
166 >       { 0, 0, 0, 0, 0 }\r
167 >      };\r
168 >  \r
169 > @@ -230,7 +235,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
170 >           }\r
171 >       }\r
172 >  \r
173 > -     if (tag_op_list_size (tag_ops) == 0) {\r
174 > +     if (tag_op_list_size (tag_ops) == 0 && !remove_all) {\r
175 >           fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");\r
176 >           return 1;\r
177 >       }\r
178 > @@ -252,7 +257,10 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
179 >       return 1;\r
180 >  \r
181 >      if (notmuch_config_get_maildir_synchronize_flags (config))\r
182 > -     synchronize_flags = TAG_FLAG_MAILDIR_SYNC;\r
183 > +     flags |= TAG_FLAG_MAILDIR_SYNC;\r
184 > +\r
185 > +    if (remove_all)\r
186 > +     flags |= TAG_FLAG_REMOVE_ALL;\r
187 >  \r
188 >      if (batch) {\r
189 >  \r
190 > @@ -280,14 +288,14 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
191 >               continue;\r
192 >  \r
193 >           if (ret < 0 || tag_query (ctx, notmuch, query_string,\r
194 > -                                   tag_ops, synchronize_flags))\r
195 > +                                   tag_ops, flags))\r
196 >               break;\r
197 >       }\r
198 >  \r
199 >       if (line)\r
200 >           free (line);\r
201 >      } else\r
202 > -     ret = tag_query (ctx, notmuch, query_string, tag_ops, synchronize_flags);\r
203 > +     ret = tag_query (ctx, notmuch, query_string, tag_ops, flags);\r
204 >  \r
205 >      notmuch_database_destroy (notmuch);\r
206 >  \r
207 > -- \r
208 > 1.7.10.4\r
209 >\r
210 > _______________________________________________\r
211 > notmuch mailing list\r
212 > notmuch@notmuchmail.org\r
213 > http://notmuchmail.org/mailman/listinfo/notmuch\r