This file describes the schemata used for notmuch's structured output
-format (currently JSON).
+format (currently JSON and S-Expressions).
[]'s indicate lists. List items can be marked with a '?', meaning
they are optional; or a '*', meaning there can be zero or more of that
alternates (e.g., int|string means something can be an int or a
string).
+For S-Expression output, lists are printed delimited by () instead of
+[]. Objects are printed as p-lists, i.e. lists where the keys and values
+are interleaved. Keys are printed as keywords (symbols preceded by a
+colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as
+nil, true as t and false as nil.
+
Common non-terminals
--------------------
enum {
FORMAT_DEFAULT,
FORMAT_JSON,
+ FORMAT_SEXP,
FORMAT_HEADERS_ONLY,
};
{ NOTMUCH_OPT_KEYWORD, &format, "format", 'f',
(notmuch_keyword_t []){ { "default", FORMAT_DEFAULT },
{ "json", FORMAT_JSON },
+ { "sexp", FORMAT_SEXP },
{ "headers-only", FORMAT_HEADERS_ONLY },
{ 0, 0 } } },
{ NOTMUCH_OPT_KEYWORD, &reply_all, "reply-to", 'r',
} else if (format == FORMAT_JSON) {
reply_format_func = notmuch_reply_format_sprinter;
sp = sprinter_json_create (ctx, stdout);
+ } else if (format == FORMAT_SEXP) {
+ reply_format_func = notmuch_reply_format_sprinter;
+ sp = sprinter_sexp_create (ctx, stdout);
} else {
reply_format_func = notmuch_reply_format_default;
}
int exclude = EXCLUDE_TRUE;
unsigned int i;
- enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
+ enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP }
format_sel = NOTMUCH_FORMAT_TEXT;
notmuch_opt_desc_t options[] = {
{ 0, 0 } } },
{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
(notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
+ { "sexp", NOTMUCH_FORMAT_SEXP },
{ "text", NOTMUCH_FORMAT_TEXT },
{ 0, 0 } } },
{ NOTMUCH_OPT_KEYWORD, &output, "output", 'o',
case NOTMUCH_FORMAT_JSON:
format = sprinter_json_create (ctx, stdout);
break;
+ case NOTMUCH_FORMAT_SEXP:
+ format = sprinter_sexp_create (ctx, stdout);
+ break;
default:
/* this should never happen */
INTERNAL_ERROR("no output format selected");
.part = format_part_sprinter_entry,
};
+static const notmuch_show_format_t format_sexp = {
+ .new_sprinter = sprinter_sexp_create,
+ .part = format_part_sprinter_entry,
+};
+
static notmuch_status_t
format_part_mbox (const void *ctx, sprinter_t *sp, mime_node_t *node,
int indent, const notmuch_show_params_t *params);
static void
format_message_sprinter (sprinter_t *sp, notmuch_message_t *message)
{
- /* Any changes to the JSON format should be reflected in the file
- * devel/schemata. */
+ /* Any changes to the JSON or S-Expression format should be
+ * reflected in the file devel/schemata. */
void *local = talloc_new (NULL);
notmuch_tags_t *tags;
format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
notmuch_bool_t reply)
{
- /* Any changes to the JSON format should be reflected in the file
- * devel/schemata. */
+ /* Any changes to the JSON or S-Expression format should be
+ * reflected in the file devel/schemata. */
InternetAddressList *recipients;
const char *recipients_string;
static void
format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
{
- /* Any changes to the JSON format should be reflected in the file
- * devel/schemata. */
+ /* Any changes to the JSON or S-Expression format should be
+ * reflected in the file devel/schemata. */
GMimeSignatureList *siglist = node->sig_list;
format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
notmuch_bool_t first, notmuch_bool_t output_body)
{
- /* Any changes to the JSON format should be reflected in the file
- * devel/schemata. */
+ /* Any changes to the JSON or S-Expression format should be
+ * reflected in the file devel/schemata. */
if (node->envelope_file) {
sp->begin_map (sp);
enum {
NOTMUCH_FORMAT_NOT_SPECIFIED,
NOTMUCH_FORMAT_JSON,
+ NOTMUCH_FORMAT_SEXP,
NOTMUCH_FORMAT_TEXT,
NOTMUCH_FORMAT_MBOX,
NOTMUCH_FORMAT_RAW
{ NOTMUCH_OPT_KEYWORD, &format_sel, "format", 'f',
(notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
{ "text", NOTMUCH_FORMAT_TEXT },
+ { "sexp", NOTMUCH_FORMAT_SEXP },
{ "mbox", NOTMUCH_FORMAT_MBOX },
{ "raw", NOTMUCH_FORMAT_RAW },
{ 0, 0 } } },
case NOTMUCH_FORMAT_TEXT:
format = &format_text;
break;
+ case NOTMUCH_FORMAT_SEXP:
+ format = &format_sexp;
+ break;
case NOTMUCH_FORMAT_MBOX:
if (params.part > 0) {
fprintf (stderr, "Error: specifying parts is incompatible with mbox output format.\n");
break;
}
- /* Default is entire-thread = FALSE except for format=json. */
+ /* Default is entire-thread = FALSE except for format=json and
+ * format=sexp. */
if (entire_thread == ENTIRE_THREAD_DEFAULT) {
- if (format == &format_json)
+ if (format == &format_json || format == &format_sexp)
entire_thread = ENTIRE_THREAD_TRUE;
else
entire_thread = ENTIRE_THREAD_FALSE;
fprintf (stderr, "Warning: --body=false is incompatible with --part > 0. Disabling.\n");
params.output_body = TRUE;
} else {
- if (format != &format_json)
- fprintf (stderr, "Warning: --body=false only implemented for format=json\n");
+ if (format != &format_json && format != &format_sexp)
+ fprintf (stderr,
+ "Warning: --body=false only implemented for format=json and format=sexp\n");
}
}