Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 615A2431FC0 for ; Thu, 19 Jul 2012 23:34:53 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.001 X-Spam-Level: X-Spam-Status: No, score=0.001 tagged_above=-999 required=5 tests=[FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x0Zwi+6igxGo for ; Thu, 19 Jul 2012 23:34:51 -0700 (PDT) Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.22]) by olra.theworths.org (Postfix) with SMTP id B2EBD431FB6 for ; Thu, 19 Jul 2012 23:34:50 -0700 (PDT) Received: (qmail invoked by alias); 20 Jul 2012 06:34:44 -0000 Received: from gw.arelion.cust.net.lagis.at (EHLO dodekanex.arelion.at) [83.164.197.182] by mail.gmx.net (mp070) with SMTP; 20 Jul 2012 08:34:44 +0200 X-Authenticated: #201305 X-Provags-ID: V01U2FsdGVkX19ltEZ7s0Zl5D69fpoGnawGa8JNoDGxjLUKbKc4Wl WcG/Cy+Ar4cJby Received: by dodekanex.arelion.at (Postfix, from userid 1000) id 949F7301BF7; Fri, 20 Jul 2012 08:36:18 +0200 (CEST) From: craven@gmx.net To: notmuch@notmuchmail.org Subject: notmuch-reply: Structured Formatters Date: Fri, 20 Jul 2012 08:36:10 +0200 Message-Id: <1342766173-1344-1-git-send-email-craven@gmx.net> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <20120718194819.GP31670@mit.edu> References: <20120718194819.GP31670@mit.edu> X-Y-GMX-Trusted: 0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jul 2012 06:34:55 -0000 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.