Re: Notmuch removing messages from the index, when calling `new` two times in a row
[notmuch-archives.git] / 98 / 9a3963ac550ec83843021458190b4587736770
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 2BEEA431FBC\r
6         for <notmuch@notmuchmail.org>; Thu,  6 Dec 2012 07:17:34 -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 gChsgBz3gRmD for <notmuch@notmuchmail.org>;\r
16         Thu,  6 Dec 2012 07:17:33 -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 23F9E431FB6\r
19         for <notmuch@notmuchmail.org>; Thu,  6 Dec 2012 07:17:33 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 0467E100045;\r
22         Thu,  6 Dec 2012 17:17:30 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Peter Feigl <craven@gmx.net>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH v4 3/5] Use the S-Expression structured printer in\r
26         notmuch-show, notmuch-reply and notmuch-search.\r
27 In-Reply-To:\r
28  <9cb474a271c471f8bae8b55b0148bb970ba78ceb.1354794428.git.craven@gmx.net>\r
29 References: <cover.1354794428.git.craven@gmx.net>\r
30         <9cb474a271c471f8bae8b55b0148bb970ba78ceb.1354794428.git.craven@gmx.net>\r
31 User-Agent: Notmuch/0.14+116~g29fcdb5 (http://notmuchmail.org) Emacs/24.2.1\r
32         (x86_64-unknown-linux-gnu)\r
33 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
34         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
35         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
36 Date: Thu, 06 Dec 2012 17:17:29 +0200\r
37 Message-ID: <m2y5hbp5va.fsf@guru.guru-group.fi>\r
38 MIME-Version: 1.0\r
39 Content-Type: text/plain\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Thu, 06 Dec 2012 15:17:34 -0000\r
53 \r
54 On Thu, Dec 06 2012, Peter Feigl <craven@gmx.net> wrote:\r
55 \r
56 > This patch uses the new S-Expression printer in the notmuch CLI (show,\r
57 > search and reply). You can now use --format=sexp for any of them.\r
58 > ---\r
59 >  devel/schemata   |  8 +++++++-\r
60 >  notmuch-reply.c  |  5 +++++\r
61 >  notmuch-search.c |  6 +++++-\r
62 >  notmuch-show.c   | 35 +++++++++++++++++++++++------------\r
63 >  4 files changed, 40 insertions(+), 14 deletions(-)\r
64 >\r
65 > diff --git a/devel/schemata b/devel/schemata\r
66 > index e44da71..01181d4 100644\r
67 > --- a/devel/schemata\r
68 > +++ b/devel/schemata\r
69 > @@ -1,5 +1,5 @@\r
70 >  This file describes the schemata used for notmuch's structured output\r
71 > -format (currently JSON).\r
72 > +format (currently JSON and S-Expressions).\r
73 >  \r
74 >  []'s indicate lists.  List items can be marked with a '?', meaning\r
75 >  they are optional; or a '*', meaning there can be zero or more of that\r
76 > @@ -8,6 +8,12 @@ values.  An object field marked '?' is optional.  |'s indicate\r
77 >  alternates (e.g., int|string means something can be an int or a\r
78 >  string).\r
79 >  \r
80 > +For S-Expression output, lists are printed delimited by () instead of\r
81 > +[]. Objects are printed as p-lists, i.e. lists where the keys and values\r
82 > +are interleaved. Keys are printed as keywords (symbols preceded by a\r
83 > +colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as\r
84 > +nil, true as t and false as nil.\r
85 > +\r
86 >  Common non-terminals\r
87 >  --------------------\r
88 >  \r
89 > diff --git a/notmuch-reply.c b/notmuch-reply.c\r
90 > index 6103d6e..5f3e46c 100644\r
91 > --- a/notmuch-reply.c\r
92 > +++ b/notmuch-reply.c\r
93 > @@ -697,6 +697,7 @@ notmuch_reply_format_headers_only(void *ctx,\r
94 >  enum {\r
95 >      FORMAT_DEFAULT,\r
96 >      FORMAT_JSON,\r
97 > +    FORMAT_SEXP,\r
98 >      FORMAT_HEADERS_ONLY,\r
99 >  };\r
100 >  \r
101 > @@ -729,6 +730,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
102 >       { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',\r
103 >         (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },\r
104 >                                 { "json", FORMAT_JSON },\r
105 > +                               { "sexp", FORMAT_SEXP },\r
106 >                                 { "headers-only", FORMAT_HEADERS_ONLY },\r
107 >                                 { 0, 0 } } },\r
108 >       { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',\r
109 > @@ -750,6 +752,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
110 >      } else if (format == FORMAT_JSON) {\r
111 >       reply_format_func = notmuch_reply_format_sprinter;\r
112 >       sp = sprinter_json_create (ctx, stdout);\r
113 > +    } else if (format == FORMAT_SEXP) {\r
114 > +     reply_format_func = notmuch_reply_format_sprinter;\r
115 > +     sp = sprinter_sexp_create (ctx, stdout);\r
116 >      } else {\r
117 >       reply_format_func = notmuch_reply_format_default;\r
118 >      }\r
119 > diff --git a/notmuch-search.c b/notmuch-search.c\r
120 > index 830c4e4..6218622 100644\r
121 > --- a/notmuch-search.c\r
122 > +++ b/notmuch-search.c\r
123 > @@ -305,7 +305,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
124 >      int exclude = EXCLUDE_TRUE;\r
125 >      unsigned int i;\r
126 >  \r
127 > -    enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }\r
128 > +    enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP }\r
129 >       format_sel = NOTMUCH_FORMAT_TEXT;\r
130 >  \r
131 >      notmuch_opt_desc_t options[] = {\r
132 > @@ -315,6 +315,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
133 >                                 { 0, 0 } } },\r
134 >       { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
135 >         (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
136 > +                               { "sexp", NOTMUCH_FORMAT_SEXP },\r
137 >                                 { "text", NOTMUCH_FORMAT_TEXT },\r
138 >                                 { 0, 0 } } },\r
139 >       { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',\r
140 > @@ -347,6 +348,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
141 >      case NOTMUCH_FORMAT_JSON:\r
142 >       format = sprinter_json_create (ctx, stdout);\r
143 >       break;\r
144 > +    case NOTMUCH_FORMAT_SEXP:\r
145 > +     format = sprinter_sexp_create (ctx, stdout);\r
146 > +     break;\r
147 >      default:\r
148 >       /* this should never happen */\r
149 >       INTERNAL_ERROR("no output format selected");\r
150 > diff --git a/notmuch-show.c b/notmuch-show.c\r
151 > index 38c621f..2bd09f3 100644\r
152 > --- a/notmuch-show.c\r
153 > +++ b/notmuch-show.c\r
154 > @@ -40,6 +40,11 @@ static const notmuch_show_format_t format_json = {\r
155 >      .part = format_part_sprinter_entry,\r
156 >  };\r
157 >  \r
158 > +static const notmuch_show_format_t format_sexp = {\r
159 > +    .new_sprinter = sprinter_sexp_create,\r
160 > +    .part = format_part_sprinter_entry,\r
161 > +};\r
162 > +\r
163 >  static notmuch_status_t\r
164 >  format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
165 >                 int indent, const notmuch_show_params_t *params);\r
166 > @@ -110,8 +115,8 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)\r
167 >  static void\r
168 >  format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)\r
169 >  {\r
170 > -    /* Any changes to the JSON format should be reflected in the file\r
171 > -     * devel/schemata. */\r
172 > +    /* Any changes to the JSON or S-Expression format should be\r
173 > +     * reflected in the file devel/schemata. */\r
174 >  \r
175 >      void *local = talloc_new (NULL);\r
176 >      notmuch_tags_t *tags;\r
177 > @@ -211,8 +216,8 @@ void\r
178 >  format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,\r
179 >                    notmuch_bool_t reply)\r
180 >  {\r
181 > -    /* Any changes to the JSON format should be reflected in the file\r
182 > -     * devel/schemata. */\r
183 > +    /* Any changes to the JSON or S-Expression format should be\r
184 > +     * reflected in the file devel/schemata. */\r
185 >  \r
186 >      InternetAddressList *recipients;\r
187 >      const char *recipients_string;\r
188 > @@ -365,8 +370,8 @@ signer_status_to_string (GMimeSignerStatus x)\r
189 >  static void\r
190 >  format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)\r
191 >  {\r
192 > -    /* Any changes to the JSON format should be reflected in the file\r
193 > -     * devel/schemata. */\r
194 > +    /* Any changes to the JSON or S-Expression format should be\r
195 > +     * reflected in the file devel/schemata. */\r
196 >  \r
197 >      GMimeSignatureList *siglist = node->sig_list;\r
198 >  \r
199 > @@ -598,8 +603,8 @@ void\r
200 >  format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
201 >                 notmuch_bool_t first, notmuch_bool_t output_body)\r
202 >  {\r
203 > -    /* Any changes to the JSON format should be reflected in the file\r
204 > -     * devel/schemata. */\r
205 > +    /* Any changes to the JSON or S-Expression format should be\r
206 > +     * reflected in the file devel/schemata. */\r
207 >  \r
208 >      if (node->envelope_file) {\r
209 >       sp->begin_map (sp);\r
210 > @@ -1012,6 +1017,7 @@ do_show (void *ctx,\r
211 >  enum {\r
212 >      NOTMUCH_FORMAT_NOT_SPECIFIED,\r
213 >      NOTMUCH_FORMAT_JSON,\r
214 > +    NOTMUCH_FORMAT_SEXP,\r
215 >      NOTMUCH_FORMAT_TEXT,\r
216 >      NOTMUCH_FORMAT_MBOX,\r
217 >      NOTMUCH_FORMAT_RAW\r
218 > @@ -1056,6 +1062,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
219 >       { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
220 >         (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
221 >                                 { "text", NOTMUCH_FORMAT_TEXT },\r
222 > +                               { "sexp", NOTMUCH_FORMAT_SEXP },\r
223 >                                 { "mbox", NOTMUCH_FORMAT_MBOX },\r
224 >                                 { "raw", NOTMUCH_FORMAT_RAW },\r
225 >                                 { 0, 0 } } },\r
226 > @@ -1100,6 +1107,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
227 >      case NOTMUCH_FORMAT_TEXT:\r
228 >       format = &format_text;\r
229 >       break;\r
230 > +    case NOTMUCH_FORMAT_SEXP:\r
231 > +     format = &format_sexp;\r
232 > +     break;\r
233 >      case NOTMUCH_FORMAT_MBOX:\r
234 >       if (params.part > 0) {\r
235 >           fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");\r
236 > @@ -1118,9 +1128,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
237 >       break;\r
238 >      }\r
239 >  \r
240 > -    /* Default is entire-thread = FALSE except for format=json. */\r
241 > +    /* Default is entire-thread = FALSE except for format=json and format=sexp. */\r
242 \r
243 ... and the last formatting comment: re-fill comment so that it fits\r
244 into 80 columns (as new patch series is needed to fix the cardinal\r
245 errors w/ 'for(' & 'if(' before :) (not counting the findings others might\r
246 find). \r
247 \r
248 >      if (entire_thread == ENTIRE_THREAD_DEFAULT) {\r
249 > -     if (format == &format_json)\r
250 > +     if (format == &format_json || format == &format_sexp)\r
251 >           entire_thread = ENTIRE_THREAD_TRUE;\r
252 >       else\r
253 >           entire_thread = ENTIRE_THREAD_FALSE;\r
254 > @@ -1131,8 +1141,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
255 >           fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");\r
256 >           params.output_body = TRUE;\r
257 >       } else {\r
258 > -         if (format != &format_json)\r
259 > -             fprintf (stderr, "Warning: --body=false only implemented for format=json\n");\r
260 > +         if (format != &format_json && format != &format_sexp)\r
261 > +             fprintf (stderr,\r
262 > +                      "Warning: --body=false only implemented for format=json and format=sexp\n");\r
263 >       }\r
264 >      }\r
265 >  \r
266 > -- \r
267 > 1.8.0\r
268 >\r
269 > _______________________________________________\r
270 > notmuch mailing list\r
271 > notmuch@notmuchmail.org\r
272 > http://notmuchmail.org/mailman/listinfo/notmuch\r