notmuch-reply: Structured Formatters
authorcraven <craven@gmx.net>
Fri, 20 Jul 2012 06:36:10 +0000 (08:36 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:25 +0000 (09:48 -0800)
ce/0da2071ebb6ae776690b34a6d2d423586a2f89 [new file with mode: 0644]

diff --git a/ce/0da2071ebb6ae776690b34a6d2d423586a2f89 b/ce/0da2071ebb6ae776690b34a6d2d423586a2f89
new file mode 100644 (file)
index 0000000..f52885a
--- /dev/null
@@ -0,0 +1,90 @@
+Return-Path: <craven@gmx.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 615A2431FC0\r
+       for <notmuch@notmuchmail.org>; Thu, 19 Jul 2012 23:34:53 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.001\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
+       tests=[FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id x0Zwi+6igxGo for <notmuch@notmuchmail.org>;\r
+       Thu, 19 Jul 2012 23:34:51 -0700 (PDT)\r
+Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22])\r
+       by olra.theworths.org (Postfix) with SMTP id B2EBD431FB6\r
+       for <notmuch@notmuchmail.org>; Thu, 19 Jul 2012 23:34:50 -0700 (PDT)\r
+Received: (qmail invoked by alias); 20 Jul 2012 06:34:44 -0000\r
+Received: from gw.arelion.cust.net.lagis.at (EHLO dodekanex.arelion.at)\r
+       [83.164.197.182]\r
+       by mail.gmx.net (mp070) with SMTP; 20 Jul 2012 08:34:44 +0200\r
+X-Authenticated: #201305\r
+X-Provags-ID: V01U2FsdGVkX19ltEZ7s0Zl5D69fpoGnawGa8JNoDGxjLUKbKc4Wl\r
+       WcG/Cy+Ar4cJby\r
+Received: by dodekanex.arelion.at (Postfix, from userid 1000)\r
+       id 949F7301BF7; Fri, 20 Jul 2012 08:36:18 +0200 (CEST)\r
+From: craven@gmx.net\r
+To: notmuch@notmuchmail.org\r
+Subject: notmuch-reply: Structured Formatters\r
+Date: Fri, 20 Jul 2012 08:36:10 +0200\r
+Message-Id: <1342766173-1344-1-git-send-email-craven@gmx.net>\r
+X-Mailer: git-send-email 1.7.11.2\r
+In-Reply-To: <20120718194819.GP31670@mit.edu>\r
+References: <20120718194819.GP31670@mit.edu>\r
+X-Y-GMX-Trusted: 0\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 20 Jul 2012 06:34:55 -0000\r
+\r
+Currently there is no easy way to add support for different structured\r
+formatters (like JSON). For example, adding support for S-Expressions\r
+would result in code duplication.\r
+\r
+This patch series amends the situation by introducing structured\r
+formatters, which allow different implementations of structures like\r
+lists, maps, strings and numbers.\r
+\r
+The new code in sprinter.h and sprinter-json.c can be used instead of\r
+the current ad-hoc output in all parts of notmuch, a patch for\r
+notmuch-search.c is included.\r
+\r
+In a later patch, all other parts of notmuch should be adapted to the\r
+structured formatters, and the creation of formatters should be\r
+centralised (to make adding new formatters easier).\r
+\r
+A "structured" formatter is provided for notmuch-search that prints the\r
+current text format. This removes almost all the special-casing from\r
+notmuch-search.c.\r
+\r
+Overall diff --stat:\r
+\r
+ Makefile.local   |   2 +\r
+ notmuch-search.c | 301 +++++++++++++----------------------------------\r
+ sprinter-json.c  | 185 +++++++++++++++++++++++++++++\r
+ sprinter-text.c  | 126 ++++++++++++++++++++\r
+ sprinter.h       |  68 +++++++++++\r
+ test/json        |  34 +++---\r
+ 6 files changed, 484 insertions(+), 232 deletions(-)\r
+\r
+Changes versus v6 of this patch:\r
+- is_text_printer is now a field, not a function.\r
+- minor formatting\r
+- sprinter_text_search has been renamed to sprinter_text (as it contains\r
+  no search-specific code).\r
+- string sanitization removed from sprinter_text, the caller should\r
+  sanitize the strings.\r
+\r