unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: [PATCH v3 04/13] show: Associate an sprinter with each format
Date: Thu,  2 Aug 2012 21:14:50 -0400	[thread overview]
Message-ID: <1343956499-14543-5-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1343956499-14543-1-git-send-email-amdragon@mit.edu>

This associates an sprinter constructor with each show format and uses
this to construct the appropriate sprinter.  Currently nothing is done
with this sprinter, but the following patches will weave it through
the layers of notmuch show.
---
 notmuch-client.h |    1 +
 notmuch-show.c   |    9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/notmuch-client.h b/notmuch-client.h
index f930798..bbc0a11 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -69,6 +69,7 @@ typedef struct mime_node mime_node_t;
 struct notmuch_show_params;
 
 typedef struct notmuch_show_format {
+    struct sprinter *(*new_sprinter) (const void *ctx, FILE *stream);
     const char *message_set_start;
     notmuch_status_t (*part) (const void *ctx,
 			      struct mime_node *node, int indent,
diff --git a/notmuch-show.c b/notmuch-show.c
index d3419e4..d04943f 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -20,12 +20,14 @@
 
 #include "notmuch-client.h"
 #include "gmime-filter-reply.h"
+#include "sprinter.h"
 
 static notmuch_status_t
 format_part_text (const void *ctx, mime_node_t *node,
 		  int indent, const notmuch_show_params_t *params);
 
 static const notmuch_show_format_t format_text = {
+    .new_sprinter = sprinter_text_create,
     .part = format_part_text,
 };
 
@@ -34,6 +36,7 @@ format_part_json_entry (const void *ctx, mime_node_t *node,
 			int indent, const notmuch_show_params_t *params);
 
 static const notmuch_show_format_t format_json = {
+    .new_sprinter = sprinter_json_create,
     .message_set_start = "[",
     .part = format_part_json_entry,
     .message_set_sep = ", ",
@@ -46,6 +49,7 @@ format_part_mbox (const void *ctx, mime_node_t *node,
 		  int indent, const notmuch_show_params_t *params);
 
 static const notmuch_show_format_t format_mbox = {
+    .new_sprinter = sprinter_text_create,
     .part = format_part_mbox,
 };
 
@@ -55,6 +59,7 @@ format_part_raw (unused (const void *ctx), mime_node_t *node,
 		 unused (const notmuch_show_params_t *params));
 
 static const notmuch_show_format_t format_raw = {
+    .new_sprinter = sprinter_text_create,
     .part = format_part_raw,
 };
 
@@ -1003,6 +1008,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
     char *query_string;
     int opt_index, ret;
     const notmuch_show_format_t *format = &format_text;
+    sprinter_t *sprinter;
     notmuch_show_params_t params = {
 	.part = -1,
 	.omit_excluded = TRUE,
@@ -1130,6 +1136,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 	return 1;
     }
 
+    /* Create structure printer. */
+    sprinter = format->new_sprinter(ctx, stdout);
+
     /* If a single message is requested we do not use search_excludes. */
     if (params.part >= 0)
 	ret = do_show_single (ctx, query, format, &params);
-- 
1.7.10

  parent reply	other threads:[~2012-08-03  1:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-03  1:14 [PATCH v3 00/13] Convert notmuch show to use structure printers Austin Clements
2012-08-03  1:14 ` [PATCH v3 01/13] test: Uniformly canonicalize actual and expected JSON Austin Clements
2012-08-03  1:14 ` [PATCH v3 02/13] test: Remove unnecessary JSON canonicalization Austin Clements
2012-08-03  1:14 ` [PATCH v3 03/13] sprinter: Add a string_len method Austin Clements
2012-08-03  1:14 ` Austin Clements [this message]
2012-08-03  1:14 ` [PATCH v3 05/13] reply: Create a JSON sprinter Austin Clements
2012-08-03  1:14 ` [PATCH v3 06/13] show: Feed the sprinter down to part formatters Austin Clements
2012-08-03  1:14 ` [PATCH v3 07/13] show: Convert format_headers_json to use sprinter Austin Clements
2012-08-03  1:14 ` [PATCH v3 08/13] show: Convert format_part_sigstatus_json " Austin Clements
2012-08-03  1:14 ` [PATCH v3 09/13] show: Convert non-envelope format_part_json " Austin Clements
2012-08-03  1:14 ` [PATCH v3 10/13] show: Convert envelope " Austin Clements
2012-08-03  1:14 ` [PATCH v3 11/13] show: Convert show_message " Austin Clements
2012-08-03  1:14 ` [PATCH v3 12/13] show: Convert do_show " Austin Clements
2012-08-03  1:14 ` [PATCH v3 13/13] show: Remove now unused fields from notmuch_show_format Austin Clements
2012-08-03  9:35 ` [PATCH v3 00/13] Convert notmuch show to use structure printers Tomi Ollila
2012-08-03 23:48 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343956499-14543-5-git-send-email-amdragon@mit.edu \
    --to=amdragon@mit.edu \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).