Re:
[notmuch-archives.git] / ce / ea87e97bcb2918cd75aaab206c61c1b3250c98
1 Return-Path: <nex@nexoid.at>\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 12ED4429E3B\r
6         for <notmuch@notmuchmail.org>; Tue,  4 Dec 2012 06:46:44 -0800 (PST)\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.001\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
13         tests=[FREEMAIL_FROM=0.001] 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 owKnj6iMzzfV for <notmuch@notmuchmail.org>;\r
17         Tue,  4 Dec 2012 06:46:42 -0800 (PST)\r
18 Received: from mail.nexoid.at (www.nexoid.at [178.79.130.240])\r
19         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 3C2FD431FD7\r
22         for <notmuch@notmuchmail.org>; Tue,  4 Dec 2012 06:46:41 -0800 (PST)\r
23 Received: by mail.nexoid.at (Postfix, from userid 1000)\r
24         id 41F7B11C109; Tue,  4 Dec 2012 15:46:40 +0100 (CET)\r
25 From: Peter Feigl <craven@gmx.net>\r
26 To: notmuch@notmuchmail.org\r
27 Subject: [PATCH v2 3/5] Use the S-Expression structured printer in\r
28         notmuch-show, notmuch-reply and notmuch-search.\r
29 Date: Tue,  4 Dec 2012 15:46:20 +0100\r
30 Message-Id: <1354632382-15609-4-git-send-email-craven@gmx.net>\r
31 X-Mailer: git-send-email 1.8.0\r
32 In-Reply-To: <1354632382-15609-1-git-send-email-craven@gmx.net>\r
33 References: <1354632382-15609-1-git-send-email-craven@gmx.net>\r
34 In-Reply-To: <1354264143-30173-1-git-send-email-craven@gmx.net>\r
35 References: <1354264143-30173-1-git-send-email-craven@gmx.net>\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.13\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40         <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Tue, 04 Dec 2012 14:46:44 -0000\r
49 \r
50 This patch uses the new S-Expression printer in the notmuch CLI (show,\r
51 search and reply). You can now use --format=sexp for any of them.\r
52 ---\r
53  notmuch-reply.c  |  5 +++++\r
54  notmuch-search.c |  6 +++++-\r
55  notmuch-show.c   | 18 ++++++++++++++----\r
56  3 files changed, 24 insertions(+), 5 deletions(-)\r
57 \r
58 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
59 index 53aefa7..69fd256 100644\r
60 --- a/notmuch-reply.c\r
61 +++ b/notmuch-reply.c\r
62 @@ -697,6 +697,7 @@ notmuch_reply_format_headers_only(void *ctx,\r
63  enum {\r
64      FORMAT_DEFAULT,\r
65      FORMAT_JSON,\r
66 +    FORMAT_SEXP,\r
67      FORMAT_HEADERS_ONLY,\r
68  };\r
69  \r
70 @@ -724,6 +725,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
71         { NOTMUCH_OPT_KEYWORD, &format, "format", 'f',\r
72           (notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },\r
73                                   { "json", FORMAT_JSON },\r
74 +                                 { "sexp", FORMAT_SEXP },\r
75                                   { "headers-only", FORMAT_HEADERS_ONLY },\r
76                                   { 0, 0 } } },\r
77         { NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',\r
78 @@ -745,6 +747,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
79      } else if (format == FORMAT_JSON) {\r
80         reply_format_func = notmuch_reply_format_sprinter;\r
81         sp = sprinter_json_create (ctx, stdout);\r
82 +    } else if (format == FORMAT_SEXP) {\r
83 +       reply_format_func = notmuch_reply_format_sprinter;\r
84 +       sp = sprinter_sexp_create (ctx, stdout);\r
85      } else {\r
86         reply_format_func = notmuch_reply_format_default;\r
87      }\r
88 diff --git a/notmuch-search.c b/notmuch-search.c\r
89 index 830c4e4..6218622 100644\r
90 --- a/notmuch-search.c\r
91 +++ b/notmuch-search.c\r
92 @@ -305,7 +305,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
93      int exclude = EXCLUDE_TRUE;\r
94      unsigned int i;\r
95  \r
96 -    enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }\r
97 +    enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP }\r
98         format_sel = NOTMUCH_FORMAT_TEXT;\r
99  \r
100      notmuch_opt_desc_t options[] = {\r
101 @@ -315,6 +315,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
102                                   { 0, 0 } } },\r
103         { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
104           (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
105 +                                 { "sexp", NOTMUCH_FORMAT_SEXP },\r
106                                   { "text", NOTMUCH_FORMAT_TEXT },\r
107                                   { 0, 0 } } },\r
108         { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',\r
109 @@ -347,6 +348,9 @@ notmuch_search_command (void *ctx, int argc, char *argv[])\r
110      case NOTMUCH_FORMAT_JSON:\r
111         format = sprinter_json_create (ctx, stdout);\r
112         break;\r
113 +    case NOTMUCH_FORMAT_SEXP:\r
114 +       format = sprinter_sexp_create (ctx, stdout);\r
115 +       break;\r
116      default:\r
117         /* this should never happen */\r
118         INTERNAL_ERROR("no output format selected");\r
119 diff --git a/notmuch-show.c b/notmuch-show.c\r
120 index 38c621f..d4860f1 100644\r
121 --- a/notmuch-show.c\r
122 +++ b/notmuch-show.c\r
123 @@ -40,6 +40,11 @@ static const notmuch_show_format_t format_json = {\r
124      .part = format_part_sprinter_entry,\r
125  };\r
126  \r
127 +static const notmuch_show_format_t format_sexp = {\r
128 +    .new_sprinter = sprinter_sexp_create,\r
129 +    .part = format_part_sprinter_entry,\r
130 +};\r
131 +\r
132  static notmuch_status_t\r
133  format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,\r
134                   int indent, const notmuch_show_params_t *params);\r
135 @@ -110,7 +115,7 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)\r
136  static void\r
137  format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)\r
138  {\r
139 -    /* Any changes to the JSON format should be reflected in the file\r
140 +    /* Any changes to the JSON or S-Expression format should be reflected in the file\r
141       * devel/schemata. */\r
142  \r
143      void *local = talloc_new (NULL);\r
144 @@ -1012,6 +1017,7 @@ do_show (void *ctx,\r
145  enum {\r
146      NOTMUCH_FORMAT_NOT_SPECIFIED,\r
147      NOTMUCH_FORMAT_JSON,\r
148 +    NOTMUCH_FORMAT_SEXP,\r
149      NOTMUCH_FORMAT_TEXT,\r
150      NOTMUCH_FORMAT_MBOX,\r
151      NOTMUCH_FORMAT_RAW\r
152 @@ -1056,6 +1062,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
153         { NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',\r
154           (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },\r
155                                   { "text", NOTMUCH_FORMAT_TEXT },\r
156 +                                 { "sexp", NOTMUCH_FORMAT_SEXP },\r
157                                   { "mbox", NOTMUCH_FORMAT_MBOX },\r
158                                   { "raw", NOTMUCH_FORMAT_RAW },\r
159                                   { 0, 0 } } },\r
160 @@ -1100,6 +1107,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
161      case NOTMUCH_FORMAT_TEXT:\r
162         format = &format_text;\r
163         break;\r
164 +    case NOTMUCH_FORMAT_SEXP:\r
165 +       format = &format_sexp;\r
166 +       break;\r
167      case NOTMUCH_FORMAT_MBOX:\r
168         if (params.part > 0) {\r
169             fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");\r
170 @@ -1120,7 +1130,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
171  \r
172      /* Default is entire-thread = FALSE except for format=json. */\r
173      if (entire_thread == ENTIRE_THREAD_DEFAULT) {\r
174 -       if (format == &format_json)\r
175 +       if (format == &format_json || format == &format_sexp)\r
176             entire_thread = ENTIRE_THREAD_TRUE;\r
177         else\r
178             entire_thread = ENTIRE_THREAD_FALSE;\r
179 @@ -1131,8 +1141,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))\r
180             fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");\r
181             params.output_body = TRUE;\r
182         } else {\r
183 -           if (format != &format_json)\r
184 -               fprintf (stderr, "Warning: --body=false only implemented for format=json\n");\r
185 +           if (format != &format_json && format != &format_sexp)\r
186 +               fprintf (stderr, "Warning: --body=false only implemented for format=json and format=sexp\n");\r
187         }\r
188      }\r
189  \r
190 -- \r
191 1.8.0\r
192 \r