[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / 33 / 4abd3b8465364e467fa5a5287f03fbba6fe7c7
1 Return-Path: <tomi.ollila@iki.fi>\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 CD5CE431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 23 Jan 2013 05:36:58 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 OX5so3CoWSCh for <notmuch@notmuchmail.org>;\r
16         Wed, 23 Jan 2013 05:36:57 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 9B834431FAE\r
19         for <notmuch@notmuchmail.org>; Wed, 23 Jan 2013 05:36:57 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id B7B1A100086;\r
22         Wed, 23 Jan 2013 15:36:45 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH 3/5] cli: add --batch option to notmuch count\r
26 In-Reply-To:\r
27  <9465478105bbda3d21921906b7abf24dbbaa7ec9.1358273133.git.jani@nikula.org>\r
28 References: <cover.1358273133.git.jani@nikula.org>\r
29         <9465478105bbda3d21921906b7abf24dbbaa7ec9.1358273133.git.jani@nikula.org>\r
30 User-Agent: Notmuch/0.15+11~ge1e719d (http://notmuchmail.org) Emacs/24.2.1\r
31         (x86_64-unknown-linux-gnu)\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
33         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
34         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
35 Date: Wed, 23 Jan 2013 15:36:45 +0200\r
36 Message-ID: <m2a9s0hvgy.fsf@guru.guru-group.fi>\r
37 MIME-Version: 1.0\r
38 Content-Type: text/plain\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Wed, 23 Jan 2013 13:36:58 -0000\r
52 \r
53 On Tue, Jan 15 2013, Jani Nikula <jani@nikula.org> wrote:\r
54 \r
55 > Add support for reading queries from stdin, one per line, and writing\r
56 > results to stdin, one per line.\r
57 \r
58 Jani's parts LGTM, except one IMPORTANT part -- results are written\r
59 to STDOUT! (hopefully...yes) instead of STDIN! ;)\r
60 \r
61 I don't see a reason why this particular way to get counts could\r
62 not be supported in notmuch into foreseeable future; the implementation\r
63 is simple and clean.\r
64 \r
65 Next to look Mark's changes...\r
66 \r
67 Tomi\r
68 \r
69 >\r
70 > This will bring considerable performance improvements when utilized in\r
71 > Emacs notmuch-hello, especially so when running remote notmuch.\r
72 > ---\r
73 >  notmuch-count.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++--\r
74 >  1 file changed, 50 insertions(+), 2 deletions(-)\r
75 >\r
76 > diff --git a/notmuch-count.c b/notmuch-count.c\r
77 > index 0e14b48..4bc4215 100644\r
78 > --- a/notmuch-count.c\r
79 > +++ b/notmuch-count.c\r
80 > @@ -62,6 +62,27 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
81 >      return 0;\r
82 >  }\r
83 >  \r
84 > +static int\r
85 > +count_file (notmuch_database_t *notmuch, FILE *input, const char **exclude_tags,\r
86 > +         size_t exclude_tags_length, int output)\r
87 > +{\r
88 > +    char *line = NULL;\r
89 > +    ssize_t line_len;\r
90 > +    size_t line_size;\r
91 > +    int ret = 0;\r
92 > +\r
93 > +    while (!ret && (line_len = getline (&line, &line_size, input)) != -1) {\r
94 > +     chomp_newline (line);\r
95 > +     ret = print_count (notmuch, line, exclude_tags, exclude_tags_length,\r
96 > +                        output);\r
97 > +    }\r
98 > +\r
99 > +    if (line)\r
100 > +     free (line);\r
101 > +\r
102 > +    return ret;\r
103 > +}\r
104 > +\r
105 >  int\r
106 >  notmuch_count_command (void *ctx, int argc, char *argv[])\r
107 >  {\r
108 > @@ -73,6 +94,9 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
109 >      int exclude = EXCLUDE_TRUE;\r
110 >      const char **search_exclude_tags = NULL;\r
111 >      size_t search_exclude_tags_length = 0;\r
112 > +    notmuch_bool_t batch = FALSE;\r
113 > +    FILE *input = stdin;\r
114 > +    char *input_file_name = NULL;\r
115 >      int ret;\r
116 >  \r
117 >      notmuch_opt_desc_t options[] = {\r
118 > @@ -84,6 +108,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
119 >         (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
120 >                                 { "false", EXCLUDE_FALSE },\r
121 >                                 { 0, 0 } } },\r
122 > +     { NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 },\r
123 > +     { NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },\r
124 >       { 0, 0, 0, 0, 0 }\r
125 >      };\r
126 >  \r
127 > @@ -93,6 +119,21 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
128 >       return 1;\r
129 >      }\r
130 >  \r
131 > +    if (input_file_name) {\r
132 > +     batch = TRUE;\r
133 > +     input = fopen (input_file_name, "r");\r
134 > +     if (input == NULL) {\r
135 > +         fprintf (stderr, "Error opening %s for reading: %s\n",\r
136 > +                  input_file_name, strerror (errno));\r
137 > +         return 1;\r
138 > +     }\r
139 > +    }\r
140 > +\r
141 > +    if (batch && opt_index != argc) {\r
142 > +     fprintf (stderr, "--batch and query string are not compatible\n");\r
143 > +     return 1;\r
144 > +    }\r
145 > +\r
146 >      config = notmuch_config_open (ctx, NULL, NULL);\r
147 >      if (config == NULL)\r
148 >       return 1;\r
149 > @@ -112,10 +153,17 @@ notmuch_count_command (void *ctx, int argc, char *argv[])\r
150 >           (config, &search_exclude_tags_length);\r
151 >      }\r
152 >  \r
153 > -    ret = print_count (notmuch, query_str, search_exclude_tags,\r
154 > -                    search_exclude_tags_length, output);\r
155 > +    if (batch)\r
156 > +     ret = count_file (notmuch, input, search_exclude_tags,\r
157 > +                       search_exclude_tags_length, output);\r
158 > +    else\r
159 > +     ret = print_count (notmuch, query_str, search_exclude_tags,\r
160 > +                        search_exclude_tags_length, output);\r
161 >  \r
162 >      notmuch_database_destroy (notmuch);\r
163 >  \r
164 > +    if (input != stdin)\r
165 > +     fclose (input);\r
166 > +\r
167 >      return ret;\r
168 >  }\r
169 > -- \r
170 > 1.7.10.4\r
171 >\r
172 > _______________________________________________\r
173 > notmuch mailing list\r
174 > notmuch@notmuchmail.org\r
175 > http://notmuchmail.org/mailman/listinfo/notmuch\r