Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / c9 / 22bd352b52d6505fe5bf83a45a1aa8aafbf5f8
1 Return-Path: <cworth@cworth.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 49304429E20\r
6         for <notmuch@notmuchmail.org>; Mon, 24 Jan 2011 22:39:29 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1 tagged_above=-999 required=5\r
12         tests=[ALL_TRUSTED=-1] 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 Ba5CEj8Omrf6; Mon, 24 Jan 2011 22:39:27 -0800 (PST)\r
16 Received: from yoom.amr.corp.intel.com (localhost [127.0.0.1])\r
17         by olra.theworths.org (Postfix) with ESMTP id D9CA0431FB6;\r
18         Mon, 24 Jan 2011 22:39:25 -0800 (PST)\r
19 From: Carl Worth <cworth@cworth.org>\r
20 To: notmuch@notmuchmail.org\r
21 Subject: [PATCH] Add --include-duplicates option to a couple of commands.\r
22 Date: Tue, 25 Jan 2011 16:39:24 +1000\r
23 Message-Id: <1295937564-2518-1-git-send-email-cworth@cworth.org>\r
24 X-Mailer: git-send-email 1.7.2.3\r
25 MIME-Version: 1.0\r
26 Content-Type: text/plain; charset=UTF-8\r
27 Content-Transfer-Encoding: 8bit\r
28 X-BeenThere: notmuch@notmuchmail.org\r
29 X-Mailman-Version: 2.1.13\r
30 Precedence: list\r
31 List-Id: "Use and development of the notmuch mail system."\r
32         <notmuch.notmuchmail.org>\r
33 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
34         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
35 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
36 List-Post: <mailto:notmuch@notmuchmail.org>\r
37 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
38 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
39         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
40 X-List-Received-Date: Tue, 25 Jan 2011 06:39:29 -0000\r
41 \r
42 This adds new functionality under the names of:\r
43 \r
44         notmuch search --output=files --include-duplicates\r
45         notmuch show --include-duplicates\r
46         notmuch show --format=json --include-duplicates\r
47 \r
48 These new commands behave similarly to the existing commands without\r
49 the --include-duplicates agument. The difference is that with the new\r
50 argument any duplicate mail files will be included in the\r
51 output. Here, files are considered duplicates if they contain\r
52 identical contents for the Message-Id header, (regardless of any other\r
53 differences in the content of the file). Without the\r
54 --include-duplicates argument, these commands would emit a single,\r
55 arbitrary file in the face of duplicates.\r
56 \r
57 WARNING: This commit is not yet ready to be pushed to the notmuch\r
58 repository. There are at least two problems with the commit so far:\r
59 \r
60         1. Nothing has been documented yet.\r
61 \r
62            Fixing this shouldn't be too hard. It's mostly just taking\r
63            the text from above and shoving it into the\r
64            documentation. I can do this easily enough myself.\r
65 \r
66         2. show --format=json --include-duplicates doesn't work yet\r
67 \r
68            This is a more serious problem. I believe the JSON output\r
69            with this patch is not correct and will likely break a\r
70            client trying to consume it. It inserts the duplicate\r
71            message into an array next to the existing message. Our\r
72            current JSON schema isn't documented formally that I could\r
73            find, except for a comment in the emacs code that consumes\r
74            it:\r
75 \r
76                 A thread is a forest or list of trees. A tree is a two\r
77                 element list where the first element is a message, and\r
78                 the second element is a possibly empty forest of\r
79                 replies.\r
80 \r
81            I believe this commit breaks the "two-element list"\r
82            expectation. What we would want instead is the duplicate\r
83            message to appear as a peer next to the original message,\r
84            (and then perhaps have replies appear only to one of the\r
85            messages).\r
86 \r
87 My current need for --include-duplicates was recently satisfied, so I\r
88 won't likely pursue this further for now. But I wanted to put this\r
89 code out rather than losing it.\r
90 \r
91 If someone wants to fix the patch to do the "right thing" with the\r
92 JSON output, then that would be great.\r
93 \r
94 ALSO NOTE: I left the\r
95 json.expected-output/notmuch-show-thread-format-json-maildir-storage\r
96 out of this commit. It has lines in it that are too long to be sent\r
97 via git-send-email.\r
98 ---\r
99  notmuch-search.c                                   |   30 +++++-\r
100  notmuch-show.c                                     |   61 +++++++++--\r
101  test/basic                                         |    2 +-\r
102  test/json                                          |   33 ++++++-\r
103  ...-show-thread-include-duplicates-maildir-storage |   94 ++++++++++++++++\r
104  .../notmuch-show-thread-maildir-storage            |   47 ++++++++\r
105  test/search-output                                 |  113 ++++++++++++++++++++\r
106  7 files changed, 361 insertions(+), 19 deletions(-)\r
107  create mode 100644 test/json.expected-output/notmuch-show-thread-include-duplicates-maildir-storage\r
108  create mode 100644 test/json.expected-output/notmuch-show-thread-maildir-storage\r
109 \r
110 diff --git a/notmuch-search.c b/notmuch-search.c\r
111 index c628b36..6d032c2 100644\r
112 --- a/notmuch-search.c\r
113 +++ b/notmuch-search.c\r
114 @@ -247,7 +247,8 @@ static int\r
115  do_search_messages (const void *ctx,\r
116                     const search_format_t *format,\r
117                     notmuch_query_t *query,\r
118 -                   output_t output)\r
119 +                   output_t output,\r
120 +                   notmuch_bool_t include_duplicates)\r
121  {\r
122      notmuch_message_t *message;\r
123      notmuch_messages_t *messages;\r
124 @@ -269,8 +270,25 @@ do_search_messages (const void *ctx,\r
125             fputs (format->item_sep, stdout);\r
126  \r
127         if (output == OUTPUT_FILES) {\r
128 -           format->item_id (ctx, "",\r
129 -                            notmuch_message_get_filename (message));\r
130 +           if (include_duplicates) {\r
131 +               notmuch_filenames_t *filenames;\r
132 +               int first_filename = 1;\r
133 +\r
134 +               for (filenames = notmuch_message_get_filenames (message);\r
135 +                    notmuch_filenames_valid (filenames);\r
136 +                    notmuch_filenames_move_to_next (filenames))\r
137 +               {\r
138 +                   if (! first_filename)\r
139 +                       fputs (format->item_sep, stdout);\r
140 +                   first_filename = 0;\r
141 +\r
142 +                   format->item_id (ctx, "",\r
143 +                                    notmuch_filenames_get (filenames));\r
144 +               }\r
145 +           } else {\r
146 +               format->item_id (ctx, "",\r
147 +                                notmuch_message_get_filename (message));\r
148 +           }\r
149         } else { /* output == OUTPUT_MESSAGES */\r
150             format->item_id (ctx, "id:",\r
151                              notmuch_message_get_message_id (message));\r
152 @@ -352,6 +370,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
153      const search_format_t *format = &format_text;\r
154      int i, ret;\r
155      output_t output = OUTPUT_SUMMARY;\r
156 +    notmuch_bool_t include_duplicates = 0;\r
157  \r
158      for (i = 0; i < argc && argv[i][0] == '-'; i++) {\r
159         if (strcmp (argv[i], "--") == 0) {\r
160 @@ -394,6 +413,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
161                 fprintf (stderr, "Invalid value for --output: %s\n", opt);\r
162                 return 1;\r
163             }\r
164 +       } else if (STRNCMP_LITERAL (argv[i], "--include-duplicates") == 0) {\r
165 +           include_duplicates = 1;\r
166         } else {\r
167             fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
168             return 1;\r
169 @@ -438,7 +459,8 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
170         break;\r
171      case OUTPUT_MESSAGES:\r
172      case OUTPUT_FILES:\r
173 -       ret = do_search_messages (ctx, format, query, output);\r
174 +       ret = do_search_messages (ctx, format, query, output,\r
175 +                                 include_duplicates);\r
176         break;\r
177      case OUTPUT_TAGS:\r
178         ret = do_search_tags (ctx, notmuch, format, query);\r
179 diff --git a/notmuch-show.c b/notmuch-show.c\r
180 index ef421ec..3fbbeac 100644\r
181 --- a/notmuch-show.c\r
182 +++ b/notmuch-show.c\r
183 @@ -463,7 +463,11 @@ format_part_json (GMimeObject *part, int *part_count)\r
184  }\r
185  \r
186  static void\r
187 -show_message (void *ctx, const show_format_t *format, notmuch_message_t *message, int indent)\r
188 +show_message (void *ctx,\r
189 +             const show_format_t *format,\r
190 +             notmuch_message_t *message,\r
191 +             const char *filename,\r
192 +             int indent)\r
193  {\r
194      fputs (format->message_start, stdout);\r
195      if (format->message)\r
196 @@ -476,18 +480,22 @@ show_message (void *ctx, const show_format_t *format, notmuch_message_t *message\r
197  \r
198      fputs (format->body_start, stdout);\r
199      if (format->part)\r
200 -       show_message_body (notmuch_message_get_filename (message), format->part);\r
201 +       show_message_body (filename, format->part);\r
202      fputs (format->body_end, stdout);\r
203  \r
204      fputs (format->message_end, stdout);\r
205  }\r
206  \r
207 -\r
208  static void\r
209 -show_messages (void *ctx, const show_format_t *format, notmuch_messages_t *messages, int indent,\r
210 -              notmuch_bool_t entire_thread)\r
211 +show_messages (void *ctx,\r
212 +              const show_format_t *format,\r
213 +              notmuch_messages_t *messages,\r
214 +              int indent,\r
215 +              notmuch_bool_t entire_thread,\r
216 +              notmuch_bool_t include_duplicates)\r
217  {\r
218      notmuch_message_t *message;\r
219 +    const char *filename;\r
220      notmuch_bool_t match;\r
221      int first_set = 1;\r
222      int next_indent;\r
223 @@ -498,7 +506,7 @@ show_messages (void *ctx, const show_format_t *format, notmuch_messages_t *messa\r
224          notmuch_messages_valid (messages);\r
225          notmuch_messages_move_to_next (messages))\r
226      {\r
227 -       if (!first_set)\r
228 +       if (! first_set)\r
229             fputs (format->message_set_sep, stdout);\r
230         first_set = 0;\r
231  \r
232 @@ -511,14 +519,38 @@ show_messages (void *ctx, const show_format_t *format, notmuch_messages_t *messa\r
233         next_indent = indent;\r
234  \r
235         if (match || entire_thread) {\r
236 -           show_message (ctx, format, message, indent);\r
237 +\r
238 +           if (include_duplicates) {\r
239 +               notmuch_filenames_t *filenames;\r
240 +               int first_filename = 1;\r
241 +\r
242 +               for (filenames = notmuch_message_get_filenames (message);\r
243 +                    notmuch_filenames_valid (filenames);\r
244 +                    notmuch_filenames_move_to_next (filenames))\r
245 +               {\r
246 +                   if (! first_filename) {\r
247 +                       fputs (format->message_set_end, stdout);\r
248 +                       fputs (format->message_set_sep, stdout);\r
249 +                       fputs (format->message_set_start, stdout);\r
250 +                   }\r
251 +                   first_filename = 0;\r
252 +\r
253 +                   filename = notmuch_filenames_get (filenames);\r
254 +\r
255 +                   show_message (ctx, format, message, filename, indent);\r
256 +               }\r
257 +           } else {\r
258 +               filename = notmuch_message_get_filename (message);\r
259 +               show_message (ctx, format, message, filename, indent);\r
260 +           }\r
261 +\r
262             next_indent = indent + 1;\r
263  \r
264             fputs (format->message_set_sep, stdout);\r
265         }\r
266  \r
267         show_messages (ctx, format, notmuch_message_get_replies (message),\r
268 -                      next_indent, entire_thread);\r
269 +                      next_indent, entire_thread, include_duplicates);\r
270  \r
271         notmuch_message_destroy (message);\r
272  \r
273 @@ -579,7 +611,8 @@ static int\r
274  do_show (void *ctx,\r
275          notmuch_query_t *query,\r
276          const show_format_t *format,\r
277 -        int entire_thread)\r
278 +        notmuch_bool_t entire_thread,\r
279 +        notmuch_bool_t include_duplicates)\r
280  {\r
281      notmuch_threads_t *threads;\r
282      notmuch_thread_t *thread;\r
283 @@ -604,7 +637,8 @@ do_show (void *ctx,\r
284             fputs (format->message_set_sep, stdout);\r
285         first_toplevel = 0;\r
286  \r
287 -       show_messages (ctx, format, messages, 0, entire_thread);\r
288 +       show_messages (ctx, format, messages, 0,\r
289 +                      entire_thread, include_duplicates);\r
290  \r
291         notmuch_thread_destroy (thread);\r
292  \r
293 @@ -624,7 +658,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
294      char *query_string;\r
295      char *opt;\r
296      const show_format_t *format = &format_text;\r
297 -    int entire_thread = 0;\r
298 +    notmuch_bool_t entire_thread = 0;\r
299 +    notmuch_bool_t include_duplicates = 0;\r
300      int i;\r
301      int raw = 0;\r
302  \r
303 @@ -650,6 +685,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
304             }\r
305         } else if (STRNCMP_LITERAL (argv[i], "--entire-thread") == 0) {\r
306             entire_thread = 1;\r
307 +       } else if (STRNCMP_LITERAL (argv[i], "--include-duplicates") == 0) {\r
308 +           include_duplicates = 1;\r
309         } else {\r
310             fprintf (stderr, "Unrecognized option: %s\n", argv[i]);\r
311             return 1;\r
312 @@ -688,7 +725,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
313      if (raw)\r
314         return do_show_raw (ctx, query);\r
315      else\r
316 -       return do_show (ctx, query, format, entire_thread);\r
317 +       return do_show (ctx, query, format, entire_thread, include_duplicates);\r
318  \r
319      notmuch_query_destroy (query);\r
320      notmuch_database_close (notmuch);\r
321 diff --git a/test/basic b/test/basic\r
322 index e1269e2..a8e2dd7 100755\r
323 --- a/test/basic\r
324 +++ b/test/basic\r
325 @@ -52,7 +52,7 @@ test_expect_code 2 'failure to clean up causes the test to fail' '\r
326  # Ensure that all tests are being run\r
327  test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
328  tests_in_suite=$(grep TESTS= ../notmuch-test | sed -e "s/TESTS=\"\(.*\)\"/\1/" | tr " " "\n" | sort)\r
329 -available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind|corpus*|emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose|test.expected-output|.*~)" | sort)\r
330 +available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind|corpus*|emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose|.*.expected-output|.*~)" | sort)\r
331  test_expect_equal "$tests_in_suite" "$available"\r
332  \r
333  EXPECTED=../test.expected-output\r
334 diff --git a/test/json b/test/json\r
335 index 7fe2a27..f2349cc 100755\r
336 --- a/test/json\r
337 +++ b/test/json\r
338 @@ -2,12 +2,21 @@\r
339  test_description="--format=json output"\r
340  . ./test-lib.sh\r
341  \r
342 -test_begin_subtest "Show message: json"\r
343 +EXPECTED=../json.expected-output\r
344 +\r
345 +add_email_corpus\r
346 +\r
347 +# Setup a duplicate message for testing\r
348 +cp "$MAIL_DIR/cur/03:2," "$MAIL_DIR/cur/03:2-duplicate,"\r
349 +increment_mtime "$MAIL_DIR/cur"\r
350 +notmuch new >/dev/null\r
351 +\r
352 +test_begin_subtest "Show single message: --format=json"\r
353  add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\""\r
354  output=$(notmuch show --format=json "json-show-message")\r
355  test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Cc\": \"\", \"Bcc\": \"\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 -0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"\r
356  \r
357 -test_begin_subtest "Search message: json"\r
358 +test_begin_subtest "Search single message: --format=json"\r
359  add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""\r
360  output=$(notmuch search --format=json "json-search-message" | notmuch_search_sanitize)\r
361  test_expect_equal "$output" "[{\"thread\": \"XXX\",\r
362 @@ -18,6 +27,26 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\",\r
363  \"subject\": \"json-search-subject\",\r
364  \"tags\": [\"inbox\", \"unread\"]}]"\r
365  \r
366 +test_begin_subtest "Show thread:"\r
367 +output=$(notmuch show id:20091117190054.GU3165@dottiness.seas.harvard.edu)\r
368 +expected=$(cat $EXPECTED/notmuch-show-thread-maildir-storage)\r
369 +test_expect_equal "$output" "$expected"\r
370 +\r
371 +test_begin_subtest "Show thread: --include-duplicates"\r
372 +output=$(notmuch show --include-duplicates id:20091117190054.GU3165@dottiness.seas.harvard.edu)\r
373 +expected=$(cat $EXPECTED/notmuch-show-thread-include-duplicates-maildir-storage)\r
374 +test_expect_equal "$output" "$expected"\r
375 +\r
376 +test_begin_subtest "Show thread: --format=json"\r
377 +output=$(notmuch show --format=json id:20091117190054.GU3165@dottiness.seas.harvard.edu)\r
378 +expected=$(cat $EXPECTED/notmuch-show-thread-format-json-maildir-storage)\r
379 +test_expect_equal "$output" "$expected"\r
380 +\r
381 +test_begin_subtest "Show thread: --format=json --include-duplicates"\r
382 +output=$(notmuch show --format=json --include-duplicates id:20091117190054.GU3165@dottiness.seas.harvard.edu)\r
383 +expected=$(cat $EXPECTED/notmuch-show-thread-format-json-include-duplicates-maildir-storage)\r
384 +test_expect_equal "$output" "$expected"\r
385 +\r
386  test_begin_subtest "Search by subject (utf-8):"\r
387  add_message [subject]=utf8-sübjéct "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\""\r
388  output=$(notmuch search subject:utf8-sübjéct | notmuch_search_sanitize)\r
389 diff --git a/test/json.expected-output/notmuch-show-thread-include-duplicates-maildir-storage b/test/json.expected-output/notmuch-show-thread-include-duplicates-maildir-storage\r
390 new file mode 100644\r
391 index 0000000..d6e8816\r
392 --- /dev/null\r
393 +++ b/test/json.expected-output/notmuch-show-thread-include-duplicates-maildir-storage\r
394 @@ -0,0 +1,94 @@\r
395 +\f\r
396 message{ id:20091117190054.GU3165@dottiness.seas.harvard.edu depth:0 match:1 filename:/home/cworth/src/notmuch/test/tmp.json/mail/cur/03:2,\r
397 +\f\r
398 header{\r
399 +Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox unread)\r
400 +Subject: [notmuch] Working with Maildir storage?\r
401 +From: Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
402 +To: notmuch@notmuchmail.org\r
403 +Date: Tue, 17 Nov 2009 14:00:54 -0500\r
404 +\f\r
405 header}\r
406 +\f\r
407 body{\r
408 +\f\r
409 part{ ID: 1, Content-type: text/plain\r
410 +I saw the LWN article and decided to take a look at notmuch.  I'm\r
411 +currently using mutt and mairix to index and read a collection of\r
412 +Maildir mail folders (around 40,000 messages total).\r
413 +\r
414 +notmuch indexed the messages without complaint, but my attempt at\r
415 +searching bombed out. Running, for example:\r
416 +\r
417 +  notmuch search storage\r
418 +\r
419 +Resulted in 4604 lines of errors along the lines of:\r
420 +\r
421 +  Error opening\r
422 +  /home/lars/Mail/read-messages.2008/cur/1246413773.24928_27334.hostname,U=3026:2,S:\r
423 +  Too many open files\r
424 +\r
425 +I'm curious if this is expected behavior (i.e., notmuch does not work\r
426 +with Maildir) or if something else is going on.\r
427 +\r
428 +Cheers,\r
429 +\r
430 +-- \r
431 +Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
432 +Senior Technologist, Computing and Information Technology\r
433 +Harvard University School of Engineering and Applied Sciences\r
434 +\r
435 +\f\r
436 part}\r
437 +\f\r
438 part{ ID: 2, Content-type: application/pgp-signature\r
439 +Non-text part: application/pgp-signature\r
440 +\f\r
441 part}\r
442 +\f\r
443 part{ ID: 3, Content-type: text/plain\r
444 +_______________________________________________\r
445 +notmuch mailing list\r
446 +notmuch@notmuchmail.org\r
447 +http://notmuchmail.org/mailman/listinfo/notmuch\r
448 +\f\r
449 part}\r
450 +\f\r
451 body}\r
452 +\f\r
453 message}\r
454 +\f\r
455 message{ id:20091117190054.GU3165@dottiness.seas.harvard.edu depth:0 match:1 filename:/home/cworth/src/notmuch/test/tmp.json/mail/cur/03:2,\r
456 +\f\r
457 header{\r
458 +Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox unread)\r
459 +Subject: [notmuch] Working with Maildir storage?\r
460 +From: Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
461 +To: notmuch@notmuchmail.org\r
462 +Date: Tue, 17 Nov 2009 14:00:54 -0500\r
463 +\f\r
464 header}\r
465 +\f\r
466 body{\r
467 +\f\r
468 part{ ID: 1, Content-type: text/plain\r
469 +I saw the LWN article and decided to take a look at notmuch.  I'm\r
470 +currently using mutt and mairix to index and read a collection of\r
471 +Maildir mail folders (around 40,000 messages total).\r
472 +\r
473 +notmuch indexed the messages without complaint, but my attempt at\r
474 +searching bombed out. Running, for example:\r
475 +\r
476 +  notmuch search storage\r
477 +\r
478 +Resulted in 4604 lines of errors along the lines of:\r
479 +\r
480 +  Error opening\r
481 +  /home/lars/Mail/read-messages.2008/cur/1246413773.24928_27334.hostname,U=3026:2,S:\r
482 +  Too many open files\r
483 +\r
484 +I'm curious if this is expected behavior (i.e., notmuch does not work\r
485 +with Maildir) or if something else is going on.\r
486 +\r
487 +Cheers,\r
488 +\r
489 +-- \r
490 +Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
491 +Senior Technologist, Computing and Information Technology\r
492 +Harvard University School of Engineering and Applied Sciences\r
493 +\r
494 +\f\r
495 part}\r
496 +\f\r
497 part{ ID: 2, Content-type: application/pgp-signature\r
498 +Non-text part: application/pgp-signature\r
499 +\f\r
500 part}\r
501 +\f\r
502 part{ ID: 3, Content-type: text/plain\r
503 +_______________________________________________\r
504 +notmuch mailing list\r
505 +notmuch@notmuchmail.org\r
506 +http://notmuchmail.org/mailman/listinfo/notmuch\r
507 +\f\r
508 part}\r
509 +\f\r
510 body}\r
511 +\f\r
512 message}\r
513 diff --git a/test/json.expected-output/notmuch-show-thread-maildir-storage b/test/json.expected-output/notmuch-show-thread-maildir-storage\r
514 new file mode 100644\r
515 index 0000000..77fefa8\r
516 --- /dev/null\r
517 +++ b/test/json.expected-output/notmuch-show-thread-maildir-storage\r
518 @@ -0,0 +1,47 @@\r
519 +\f\r
520 message{ id:20091117190054.GU3165@dottiness.seas.harvard.edu depth:0 match:1 filename:/home/cworth/src/notmuch/test/tmp.json/mail/cur/03:2,\r
521 +\f\r
522 header{\r
523 +Lars Kellogg-Stedman <lars@seas.harvard.edu> (2009-11-17) (inbox unread)\r
524 +Subject: [notmuch] Working with Maildir storage?\r
525 +From: Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
526 +To: notmuch@notmuchmail.org\r
527 +Date: Tue, 17 Nov 2009 14:00:54 -0500\r
528 +\f\r
529 header}\r
530 +\f\r
531 body{\r
532 +\f\r
533 part{ ID: 1, Content-type: text/plain\r
534 +I saw the LWN article and decided to take a look at notmuch.  I'm\r
535 +currently using mutt and mairix to index and read a collection of\r
536 +Maildir mail folders (around 40,000 messages total).\r
537 +\r
538 +notmuch indexed the messages without complaint, but my attempt at\r
539 +searching bombed out. Running, for example:\r
540 +\r
541 +  notmuch search storage\r
542 +\r
543 +Resulted in 4604 lines of errors along the lines of:\r
544 +\r
545 +  Error opening\r
546 +  /home/lars/Mail/read-messages.2008/cur/1246413773.24928_27334.hostname,U=3026:2,S:\r
547 +  Too many open files\r
548 +\r
549 +I'm curious if this is expected behavior (i.e., notmuch does not work\r
550 +with Maildir) or if something else is going on.\r
551 +\r
552 +Cheers,\r
553 +\r
554 +-- \r
555 +Lars Kellogg-Stedman <lars@seas.harvard.edu>\r
556 +Senior Technologist, Computing and Information Technology\r
557 +Harvard University School of Engineering and Applied Sciences\r
558 +\r
559 +\f\r
560 part}\r
561 +\f\r
562 part{ ID: 2, Content-type: application/pgp-signature\r
563 +Non-text part: application/pgp-signature\r
564 +\f\r
565 part}\r
566 +\f\r
567 part{ ID: 3, Content-type: text/plain\r
568 +_______________________________________________\r
569 +notmuch mailing list\r
570 +notmuch@notmuchmail.org\r
571 +http://notmuchmail.org/mailman/listinfo/notmuch\r
572 +\f\r
573 part}\r
574 +\f\r
575 body}\r
576 +\f\r
577 message}\r
578 diff --git a/test/search-output b/test/search-output\r
579 index b414993..69d4c89 100755\r
580 --- a/test/search-output\r
581 +++ b/test/search-output\r
582 @@ -4,6 +4,11 @@ test_description='various settings for "notmuch search --output="'\r
583  \r
584  add_email_corpus\r
585  \r
586 +# Setup a duplicate message for testing\r
587 +cp "$MAIL_DIR/cur/01:2," "$MAIL_DIR/cur/01:2-duplicate,"\r
588 +increment_mtime "$MAIL_DIR/cur"\r
589 +notmuch new >/dev/null\r
590 +\r
591  test_begin_subtest "notmuch search --output=threads"\r
592  output=$(notmuch search --output=threads '*' | sed -e s/thread:.*/thread:THREADID/)\r
593  test_expect_equal "$output" "thread:THREADID\r
594 @@ -213,6 +218,60 @@ MAIL_DIR/cur/07:2,\r
595  MAIL_DIR/cur/02:2,\r
596  MAIL_DIR/cur/01:2,"\r
597  \r
598 +test_begin_subtest "notmuch search --output=files --include-duplicates"\r
599 +output=$(notmuch search --output=files --include-duplicates '*' | sed -e "s,$MAIL_DIR,MAIL_DIR,")\r
600 +test_expect_equal "$output" "MAIL_DIR/cur/50:2,\r
601 +MAIL_DIR/cur/49:2,\r
602 +MAIL_DIR/cur/48:2,\r
603 +MAIL_DIR/cur/47:2,\r
604 +MAIL_DIR/cur/46:2,\r
605 +MAIL_DIR/cur/45:2,\r
606 +MAIL_DIR/cur/44:2,\r
607 +MAIL_DIR/cur/43:2,\r
608 +MAIL_DIR/cur/42:2,\r
609 +MAIL_DIR/cur/41:2,\r
610 +MAIL_DIR/cur/40:2,\r
611 +MAIL_DIR/cur/39:2,\r
612 +MAIL_DIR/cur/38:2,\r
613 +MAIL_DIR/cur/37:2,\r
614 +MAIL_DIR/cur/36:2,\r
615 +MAIL_DIR/cur/35:2,\r
616 +MAIL_DIR/cur/34:2,\r
617 +MAIL_DIR/cur/33:2,\r
618 +MAIL_DIR/cur/32:2,\r
619 +MAIL_DIR/cur/31:2,\r
620 +MAIL_DIR/cur/30:2,\r
621 +MAIL_DIR/cur/29:2,\r
622 +MAIL_DIR/cur/28:2,\r
623 +MAIL_DIR/cur/27:2,\r
624 +MAIL_DIR/cur/26:2,\r
625 +MAIL_DIR/cur/25:2,\r
626 +MAIL_DIR/cur/24:2,\r
627 +MAIL_DIR/cur/23:2,\r
628 +MAIL_DIR/cur/22:2,\r
629 +MAIL_DIR/cur/21:2,\r
630 +MAIL_DIR/cur/19:2,\r
631 +MAIL_DIR/cur/18:2,\r
632 +MAIL_DIR/cur/20:2,\r
633 +MAIL_DIR/cur/17:2,\r
634 +MAIL_DIR/cur/16:2,\r
635 +MAIL_DIR/cur/15:2,\r
636 +MAIL_DIR/cur/14:2,\r
637 +MAIL_DIR/cur/13:2,\r
638 +MAIL_DIR/cur/12:2,\r
639 +MAIL_DIR/cur/11:2,\r
640 +MAIL_DIR/cur/10:2,\r
641 +MAIL_DIR/cur/09:2,\r
642 +MAIL_DIR/cur/08:2,\r
643 +MAIL_DIR/cur/06:2,\r
644 +MAIL_DIR/cur/05:2,\r
645 +MAIL_DIR/cur/04:2,\r
646 +MAIL_DIR/cur/03:2,\r
647 +MAIL_DIR/cur/07:2,\r
648 +MAIL_DIR/cur/02:2,\r
649 +MAIL_DIR/cur/01:2,\r
650 +MAIL_DIR/cur/01:2-duplicate,"\r
651 +\r
652  test_begin_subtest "notmuch search --format=json --output=files"\r
653  output=$(notmuch search --format=json --output=files '*' | sed -e "s,$MAIL_DIR,MAIL_DIR,")\r
654  test_expect_equal "$output" '["MAIL_DIR/cur/50:2,",\r
655 @@ -266,6 +325,60 @@ test_expect_equal "$output" '["MAIL_DIR/cur/50:2,",\r
656  "MAIL_DIR/cur/02:2,",\r
657  "MAIL_DIR/cur/01:2,"]'\r
658  \r
659 +test_begin_subtest "notmuch search --format=json --output=files --include-duplicates"\r
660 +output=$(notmuch search --format=json --output=files --include-duplicates '*' | sed -e "s,$MAIL_DIR,MAIL_DIR,")\r
661 +test_expect_equal "$output" '["MAIL_DIR/cur/50:2,",\r
662 +"MAIL_DIR/cur/49:2,",\r
663 +"MAIL_DIR/cur/48:2,",\r
664 +"MAIL_DIR/cur/47:2,",\r
665 +"MAIL_DIR/cur/46:2,",\r
666 +"MAIL_DIR/cur/45:2,",\r
667 +"MAIL_DIR/cur/44:2,",\r
668 +"MAIL_DIR/cur/43:2,",\r
669 +"MAIL_DIR/cur/42:2,",\r
670 +"MAIL_DIR/cur/41:2,",\r
671 +"MAIL_DIR/cur/40:2,",\r
672 +"MAIL_DIR/cur/39:2,",\r
673 +"MAIL_DIR/cur/38:2,",\r
674 +"MAIL_DIR/cur/37:2,",\r
675 +"MAIL_DIR/cur/36:2,",\r
676 +"MAIL_DIR/cur/35:2,",\r
677 +"MAIL_DIR/cur/34:2,",\r
678 +"MAIL_DIR/cur/33:2,",\r
679 +"MAIL_DIR/cur/32:2,",\r
680 +"MAIL_DIR/cur/31:2,",\r
681 +"MAIL_DIR/cur/30:2,",\r
682 +"MAIL_DIR/cur/29:2,",\r
683 +"MAIL_DIR/cur/28:2,",\r
684 +"MAIL_DIR/cur/27:2,",\r
685 +"MAIL_DIR/cur/26:2,",\r
686 +"MAIL_DIR/cur/25:2,",\r
687 +"MAIL_DIR/cur/24:2,",\r
688 +"MAIL_DIR/cur/23:2,",\r
689 +"MAIL_DIR/cur/22:2,",\r
690 +"MAIL_DIR/cur/21:2,",\r
691 +"MAIL_DIR/cur/19:2,",\r
692 +"MAIL_DIR/cur/18:2,",\r
693 +"MAIL_DIR/cur/20:2,",\r
694 +"MAIL_DIR/cur/17:2,",\r
695 +"MAIL_DIR/cur/16:2,",\r
696 +"MAIL_DIR/cur/15:2,",\r
697 +"MAIL_DIR/cur/14:2,",\r
698 +"MAIL_DIR/cur/13:2,",\r
699 +"MAIL_DIR/cur/12:2,",\r
700 +"MAIL_DIR/cur/11:2,",\r
701 +"MAIL_DIR/cur/10:2,",\r
702 +"MAIL_DIR/cur/09:2,",\r
703 +"MAIL_DIR/cur/08:2,",\r
704 +"MAIL_DIR/cur/06:2,",\r
705 +"MAIL_DIR/cur/05:2,",\r
706 +"MAIL_DIR/cur/04:2,",\r
707 +"MAIL_DIR/cur/03:2,",\r
708 +"MAIL_DIR/cur/07:2,",\r
709 +"MAIL_DIR/cur/02:2,",\r
710 +"MAIL_DIR/cur/01:2,",\r
711 +"MAIL_DIR/cur/01:2-duplicate,"]'\r
712 +\r
713  test_begin_subtest "notmuch search --output=tags"\r
714  output=$(notmuch search --output=tags '*')\r
715  test_expect_equal "$output" "attachment\r
716 -- \r
717 1.7.2.3\r
718 \r