Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / b9 / 85eae79b8f217826a12de4cff5beaf6855069a
1 Return-Path: <jani@nikula.org>\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 BADEA431FBC\r
6         for <notmuch@notmuchmail.org>; Mon,  3 Dec 2012 14:13:01 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id Jjnh7u4QS5YC for <notmuch@notmuchmail.org>;\r
16         Mon,  3 Dec 2012 14:12:50 -0800 (PST)\r
17 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com\r
18         [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id B8064431FAE\r
21         for <notmuch@notmuchmail.org>; Mon,  3 Dec 2012 14:12:49 -0800 (PST)\r
22 Received: by mail-lb0-f181.google.com with SMTP id ge1so2940948lbb.26\r
23         for <notmuch@notmuchmail.org>; Mon, 03 Dec 2012 14:12:48 -0800 (PST)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=google.com; s=20120113;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state;\r
27         bh=HLxnVsvyKhd7lBH1iN5n8aexcrQxJjD/fNjgBNvSBsQ=;\r
28         b=D0WmJlk+KZVD4FYePw0BrHf9CCGkALbOrp0RxYOL4pey0oIK2nhW/J4GoSpRMz4uln\r
29         A7Wgj/3FlhDe15WY2gaJL8O23SoQM8WuD/szf4ezw4Cr+BAG5VQ0qZseccLyYEILBHpq\r
30         FLZNBwm/HY3QsUQyTbUnnbeua5pWtBVu38MqTfA38139Sc/Mbnc6/dq7hsFvR9hoQ0QU\r
31         7tkwK61/S+z3APPt4Z8JmhfleXTQHe0FgZGYcvAEmE0A/H0oKdLwqesqY0Ph2oZlMWcG\r
32         O12Ogk6FQFBKBsRONXIje/YWfaT3A8ArN6y9TNdvfuS3rBDVI50y1SuKCV1cf5bUiJVo\r
33         vm7A==\r
34 Received: by 10.152.106.79 with SMTP id gs15mr11029119lab.31.1354572768087;\r
35         Mon, 03 Dec 2012 14:12:48 -0800 (PST)\r
36 Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
37         [80.223.81.27])\r
38         by mx.google.com with ESMTPS id p5sm5987935lbh.2.2012.12.03.14.12.46\r
39         (version=SSLv3 cipher=OTHER); Mon, 03 Dec 2012 14:12:47 -0800 (PST)\r
40 From: Jani Nikula <jani@nikula.org>\r
41 To: notmuch@notmuchmail.org\r
42 Subject: [RFC PATCH] cli: add --remove-all option to "notmuch tag"\r
43 Date: Tue,  4 Dec 2012 00:12:44 +0200\r
44 Message-Id: <1354572764-28701-1-git-send-email-jani@nikula.org>\r
45 X-Mailer: git-send-email 1.7.10.4\r
46 X-Gm-Message-State:\r
47  ALoCoQmTXjOJlgp/oRbie+KNWitO8OyqaexHjNKf5/b/6UK2GOKZyTvfZd1KCNILYbr8XreKUkYj\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Mon, 03 Dec 2012 22:13:01 -0000\r
61 \r
62 Add --remove-all option to "notmuch tag" to remove all tags matching\r
63 query before applying the tag changes. This allows removal and\r
64 unconditional setting of the tags of a message:\r
65 \r
66 $ notmuch tag --remove-all id:foo@example.com\r
67 $ notmuch tag --remove-all +foo +bar id:foo@example.com\r
68 \r
69 without having to resort to the complicated (and still quoting broken):\r
70 \r
71 $ notmuch tag $(notmuch search --output=tags '*' | sed 's/^/-/') id:foo@example.com\r
72 $ notmuch tag $(notmuch search --output=tags '*' | sed 's/^/-/') +foo +bar id:foo@example.com\r
73 \r
74 ---\r
75 \r
76 It's completely untested...\r
77 \r
78 This is on top of David's batch tagging branch new-tagging at\r
79 git://pivot.cs.unb.ca/notmuch.git\r
80 \r
81 If there's interest, I'll spin a new version with tests and man page\r
82 changes after David's stuff has been merged.\r
83 ---\r
84  notmuch-tag.c |   32 ++++++++++++++++++++------------\r
85  1 file changed, 20 insertions(+), 12 deletions(-)\r
86 \r
87 diff --git a/notmuch-tag.c b/notmuch-tag.c\r
88 index e4fca67..67624cc 100644\r
89 --- a/notmuch-tag.c\r
90 +++ b/notmuch-tag.c\r
91 @@ -119,12 +119,15 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
92      notmuch_messages_t *messages;\r
93      notmuch_message_t *message;\r
94  \r
95 -    /* Optimize the query so it excludes messages that already have\r
96 -     * the specified set of tags. */\r
97 -    query_string = _optimize_tag_query (ctx, query_string, tag_ops);\r
98 -    if (query_string == NULL) {\r
99 -       fprintf (stderr, "Out of memory.\n");\r
100 -       return 1;\r
101 +    if (! (flags & TAG_FLAG_REMOVE_ALL)) {\r
102 +       /* Optimize the query so it excludes messages that already\r
103 +        * have the specified set of tags. */\r
104 +       query_string = _optimize_tag_query (ctx, query_string, tag_ops);\r
105 +       if (query_string == NULL) {\r
106 +           fprintf (stderr, "Out of memory.\n");\r
107 +           return 1;\r
108 +       }\r
109 +       flags |= TAG_FLAG_PRE_OPTIMIZED;\r
110      }\r
111  \r
112      query = notmuch_query_create (notmuch, query_string);\r
113 @@ -140,7 +143,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
114          notmuch_messages_valid (messages) && ! interrupted;\r
115          notmuch_messages_move_to_next (messages)) {\r
116         message = notmuch_messages_get (messages);\r
117 -       tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);\r
118 +       tag_op_list_apply (message, tag_ops, flags);\r
119         notmuch_message_destroy (message);\r
120      }\r
121  \r
122 @@ -157,8 +160,9 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
123      notmuch_config_t *config;\r
124      notmuch_database_t *notmuch;\r
125      struct sigaction action;\r
126 -    tag_op_flag_t synchronize_flags = TAG_FLAG_NONE;\r
127 +    tag_op_flag_t flags = TAG_FLAG_NONE;\r
128      notmuch_bool_t batch = FALSE;\r
129 +    notmuch_bool_t remove_all = FALSE;\r
130      FILE *input = stdin;\r
131      char *input_file_name = NULL;\r
132      int i, opt_index;\r
133 @@ -174,6 +178,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
134      notmuch_opt_desc_t options[] = {\r
135         { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 },\r
136         { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },\r
137 +       { NOTMUCH_OPT_BOOLEAN, &remove_all, "remove-all", 0, 0 },\r
138         { 0, 0, 0, 0, 0 }\r
139      };\r
140  \r
141 @@ -230,7 +235,7 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
142             }\r
143         }\r
144  \r
145 -       if (tag_op_list_size (tag_ops) == 0) {\r
146 +       if (tag_op_list_size (tag_ops) == 0 && !remove_all) {\r
147             fprintf (stderr, "Error: 'notmuch tag' requires at least one tag to add or remove.\n");\r
148             return 1;\r
149         }\r
150 @@ -252,7 +257,10 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
151         return 1;\r
152  \r
153      if (notmuch_config_get_maildir_synchronize_flags (config))\r
154 -       synchronize_flags = TAG_FLAG_MAILDIR_SYNC;\r
155 +       flags |= TAG_FLAG_MAILDIR_SYNC;\r
156 +\r
157 +    if (remove_all)\r
158 +       flags |= TAG_FLAG_REMOVE_ALL;\r
159  \r
160      if (batch) {\r
161  \r
162 @@ -280,14 +288,14 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
163                 continue;\r
164  \r
165             if (ret < 0 || tag_query (ctx, notmuch, query_string,\r
166 -                                     tag_ops, synchronize_flags))\r
167 +                                     tag_ops, flags))\r
168                 break;\r
169         }\r
170  \r
171         if (line)\r
172             free (line);\r
173      } else\r
174 -       ret = tag_query (ctx, notmuch, query_string, tag_ops, synchronize_flags);\r
175 +       ret = tag_query (ctx, notmuch, query_string, tag_ops, flags);\r
176  \r
177      notmuch_database_destroy (notmuch);\r
178  \r
179 -- \r
180 1.7.10.4\r
181 \r