Re: notmuch-reply: Structured Formatters

Subject: Re: notmuch-reply: Structured Formatters

Date: Sun, 22 Jul 2012 12:13:13 -0400

To: craven@gmx.net

Cc: notmuch@notmuchmail.org

From: Austin Clements


LGTM!  This is a great cleanup and I'm looking forward to S-expression
support.

Quoth craven@gmx.net on Jul 20 at  8:36 am:
> Currently there is no easy way to add support for different structured
> formatters (like JSON). For example, adding support for S-Expressions
> would result in code duplication.
> 
> This patch series amends the situation by introducing structured
> formatters, which allow different implementations of structures like
> lists, maps, strings and numbers.
> 
> The new code in sprinter.h and sprinter-json.c can be used instead of
> the current ad-hoc output in all parts of notmuch, a patch for
> notmuch-search.c is included.
> 
> In a later patch, all other parts of notmuch should be adapted to the
> structured formatters, and the creation of formatters should be
> centralised (to make adding new formatters easier).
> 
> A "structured" formatter is provided for notmuch-search that prints the
> current text format. This removes almost all the special-casing from
> notmuch-search.c.
> 
> Overall diff --stat:
> 
>  Makefile.local   |   2 +
>  notmuch-search.c | 301 +++++++++++++----------------------------------
>  sprinter-json.c  | 185 +++++++++++++++++++++++++++++
>  sprinter-text.c  | 126 ++++++++++++++++++++
>  sprinter.h       |  68 +++++++++++
>  test/json        |  34 +++---
>  6 files changed, 484 insertions(+), 232 deletions(-)
> 
> Changes versus v6 of this patch:
> - is_text_printer is now a field, not a function.
> - minor formatting
> - sprinter_text_search has been renamed to sprinter_text (as it contains
>   no search-specific code).
> - string sanitization removed from sprinter_text, the caller should
>   sanitize the strings.

Thread: