[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / 6d / d278a5297e8a5883917f0ff752405cf8f026f6
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 3FE34431FD6\r
6         for <notmuch@notmuchmail.org>; Sat, 24 Mar 2012 09:14:55 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 HvnZdEGv6h1z for <notmuch@notmuchmail.org>;\r
17         Sat, 24 Mar 2012 09:14:53 -0700 (PDT)\r
18 Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com\r
19         [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 7A8D1431FC9\r
22         for <notmuch@notmuchmail.org>; Sat, 24 Mar 2012 09:14:49 -0700 (PDT)\r
23 Received: by mail-lb0-f181.google.com with SMTP id k6so3358397lbo.26\r
24         for <notmuch@notmuchmail.org>; Sat, 24 Mar 2012 09:14:49 -0700 (PDT)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=google.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
28         :in-reply-to:references:x-gm-message-state;\r
29         bh=I7Ey2iPdCus0Q9WS9Qa0SBUn6KBTMElQufkGikf0vsw=;\r
30         b=aR/Zc7l0Qvqq7G7dhxuSiIeB+hQTtxjXwqVZLCgJ+HxSmpA66JOUGWlypD5/ibShZc\r
31         T7qr9Ln0+arla6Uld4LgTezs5APo0kfmHXwGlUrvcLsuWpOUbOEUjT94WaXY4oWFJNlv\r
32         pDuQI4LhICUkiJJjS1/PJXD0AOdMGDNgLcgxFeTMn87a3Tjb2C6EHJhza1EcAdiK8yq/\r
33         0HXRJ3y9buWRo4BDY2B8c0ahe8WgqMEYfHmLyAVt5m6zgsg8ou4z++sJkqgdG6RxrNAb\r
34         j6BmKLk/lKltgUSHFQjIPMlp3CaFidq1XBnTwm4i7iwpiJqSYDtwK66oTuw7nQ/KjY6U\r
35         KiTA==\r
36 Received: by 10.112.24.196 with SMTP id w4mr5923166lbf.62.1332605689045;\r
37         Sat, 24 Mar 2012 09:14:49 -0700 (PDT)\r
38 Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.\r
39         [84.248.80.253])\r
40         by mx.google.com with ESMTPS id tt5sm11392906lab.10.2012.03.24.09.14.47\r
41         (version=SSLv3 cipher=OTHER); Sat, 24 Mar 2012 09:14:48 -0700 (PDT)\r
42 From: Jani Nikula <jani@nikula.org>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH 2/3] cli: refactor "notmuch tag" query tagging into a separate\r
45         function\r
46 Date: Sat, 24 Mar 2012 18:14:36 +0200\r
47 Message-Id:\r
48  <0557d94790bd72a13cd8e6696ea6ac1708a92be5.1332604895.git.jani@nikula.org>\r
49 X-Mailer: git-send-email 1.7.5.4\r
50 In-Reply-To: <cover.1332604895.git.jani@nikula.org>\r
51 References: <cover.1332604895.git.jani@nikula.org>\r
52 In-Reply-To: <cover.1332604895.git.jani@nikula.org>\r
53 References: <cover.1332604895.git.jani@nikula.org>\r
54 X-Gm-Message-State:\r
55  ALoCoQnB/8SzztJxUALQ5qQOBClieBK5Og+uv/cSo2KGJeYw/eVDc80zdmSKHiiv4BE3xEFuIcqC\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Sat, 24 Mar 2012 16:14:55 -0000\r
69 \r
70 Refactor to make tagging code easier to reuse in the future. No\r
71 functional changes.\r
72 \r
73 Signed-off-by: Jani Nikula <jani@nikula.org>\r
74 ---\r
75  notmuch-tag.c |  101 ++++++++++++++++++++++++++++++++-------------------------\r
76  1 files changed, 57 insertions(+), 44 deletions(-)\r
77 \r
78 diff --git a/notmuch-tag.c b/notmuch-tag.c\r
79 index 98b2126..c4e3f9d 100644\r
80 --- a/notmuch-tag.c\r
81 +++ b/notmuch-tag.c\r
82 @@ -106,6 +106,60 @@ _optimize_tag_query (void *ctx, const char *orig_query_string,\r
83      return query_string;\r
84  }\r
85  \r
86 +static int\r
87 +tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,\r
88 +          tag_operation_t *tag_ops, notmuch_bool_t synchronize_flags)\r
89 +{\r
90 +    notmuch_query_t *query;\r
91 +    notmuch_messages_t *messages;\r
92 +    notmuch_message_t *message;\r
93 +    int i;\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 +    }\r
102 +\r
103 +    query = notmuch_query_create (notmuch, query_string);\r
104 +    if (query == NULL) {\r
105 +       fprintf (stderr, "Out of memory.\n");\r
106 +       return 1;\r
107 +    }\r
108 +\r
109 +    /* tagging is not interested in any special sort order */\r
110 +    notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);\r
111 +\r
112 +    for (messages = notmuch_query_search_messages (query);\r
113 +        notmuch_messages_valid (messages) && !interrupted;\r
114 +        notmuch_messages_move_to_next (messages))\r
115 +    {\r
116 +       message = notmuch_messages_get (messages);\r
117 +\r
118 +       notmuch_message_freeze (message);\r
119 +\r
120 +       for (i = 0; tag_ops[i].tag; i++) {\r
121 +           if (tag_ops[i].remove)\r
122 +               notmuch_message_remove_tag (message, tag_ops[i].tag);\r
123 +           else\r
124 +               notmuch_message_add_tag (message, tag_ops[i].tag);\r
125 +       }\r
126 +\r
127 +       notmuch_message_thaw (message);\r
128 +\r
129 +       if (synchronize_flags)\r
130 +           notmuch_message_tags_to_maildir_flags (message);\r
131 +\r
132 +       notmuch_message_destroy (message);\r
133 +    }\r
134 +\r
135 +    notmuch_query_destroy (query);\r
136 +\r
137 +    return interrupted;\r
138 +}\r
139 +\r
140  int\r
141  notmuch_tag_command (void *ctx, int argc, char *argv[])\r
142  {\r
143 @@ -114,12 +168,10 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
144      char *query_string;\r
145      notmuch_config_t *config;\r
146      notmuch_database_t *notmuch;\r
147 -    notmuch_query_t *query;\r
148 -    notmuch_messages_t *messages;\r
149 -    notmuch_message_t *message;\r
150      struct sigaction action;\r
151      notmuch_bool_t synchronize_flags;\r
152      int i;\r
153 +    int ret;\r
154  \r
155      /* Setup our handler for SIGINT */\r
156      memset (&action, 0, sizeof (struct sigaction));\r
157 @@ -167,14 +219,6 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
158         return 1;\r
159      }\r
160  \r
161 -    /* Optimize the query so it excludes messages that already have\r
162 -     * the specified set of tags. */\r
163 -    query_string = _optimize_tag_query (ctx, query_string, tag_ops);\r
164 -    if (query_string == NULL) {\r
165 -       fprintf (stderr, "Out of memory.\n");\r
166 -       return 1;\r
167 -    }\r
168 -\r
169      config = notmuch_config_open (ctx, NULL, NULL);\r
170      if (config == NULL)\r
171         return 1;\r
172 @@ -186,40 +230,9 @@ notmuch_tag_command (void *ctx, int argc, char *argv[])\r
173  \r
174      synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);\r
175  \r
176 -    query = notmuch_query_create (notmuch, query_string);\r
177 -    if (query == NULL) {\r
178 -       fprintf (stderr, "Out of memory.\n");\r
179 -       return 1;\r
180 -    }\r
181 -\r
182 -    /* tagging is not interested in any special sort order */\r
183 -    notmuch_query_set_sort (query, NOTMUCH_SORT_UNSORTED);\r
184 +    ret = tag_query (ctx, notmuch, query_string, tag_ops, synchronize_flags);\r
185  \r
186 -    for (messages = notmuch_query_search_messages (query);\r
187 -        notmuch_messages_valid (messages) && !interrupted;\r
188 -        notmuch_messages_move_to_next (messages))\r
189 -    {\r
190 -       message = notmuch_messages_get (messages);\r
191 -\r
192 -       notmuch_message_freeze (message);\r
193 -\r
194 -       for (i = 0; tag_ops[i].tag; i++) {\r
195 -           if (tag_ops[i].remove)\r
196 -               notmuch_message_remove_tag (message, tag_ops[i].tag);\r
197 -           else\r
198 -               notmuch_message_add_tag (message, tag_ops[i].tag);\r
199 -       }\r
200 -\r
201 -       notmuch_message_thaw (message);\r
202 -\r
203 -       if (synchronize_flags)\r
204 -           notmuch_message_tags_to_maildir_flags (message);\r
205 -\r
206 -       notmuch_message_destroy (message);\r
207 -    }\r
208 -\r
209 -    notmuch_query_destroy (query);\r
210      notmuch_database_close (notmuch);\r
211  \r
212 -    return interrupted;\r
213 +    return ret;\r
214  }\r
215 -- \r
216 1.7.5.4\r
217 \r