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 5F126431FC2 for ; Mon, 23 Jul 2012 03:38:27 -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 aRn3L2cOB2XY for ; Mon, 23 Jul 2012 03:38:25 -0700 (PDT) Received: from mailout-de.gmx.net (mailout-de.gmx.net [213.165.64.23]) by olra.theworths.org (Postfix) with SMTP id 30DEC431FC4 for ; Mon, 23 Jul 2012 03:38:22 -0700 (PDT) Received: (qmail invoked by alias); 23 Jul 2012 10:38:16 -0000 Received: from gw.arelion.cust.net.lagis.at (EHLO dodekanex.arelion.at) [83.164.197.182] by mail.gmx.net (mp031) with SMTP; 23 Jul 2012 12:38:16 +0200 X-Authenticated: #201305 X-Provags-ID: V01U2FsdGVkX18W3nk9VzAWOkyRZ7d2BH0dr/pOH/nDBARUmc1+LB SUC1rmGoyyXjs4 Received: by dodekanex.arelion.at (Postfix, from userid 1000) id 91B323034D3; Mon, 23 Jul 2012 12:39:50 +0200 (CEST) From: craven@gmx.net To: notmuch@notmuchmail.org Subject: [PATCH v8 0/3] notmuch-search: Structured Output Formatters Date: Mon, 23 Jul 2012 12:39:43 +0200 Message-Id: <1343039986-2732-1-git-send-email-craven@gmx.net> X-Mailer: git-send-email 1.7.11.2 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: Mon, 23 Jul 2012 10:38:27 -0000 From: 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. Changes versus v7 of this patch: - added {} around "else" blocks (as mentioned in id:20120722160843.GC31834@mit.edu) - added fallback to INTERNAL_ERROR (which should never be called) in notmuch-search.c if format is unknown (as mentioned in id:m2r4s694ly.fsf@guru.guru-group.fi). Summary: Peter Feigl (3): Add support for structured output formatters. Add structured output formatter for JSON and plain text (but don't use them yet). Use the structured formatters in notmuch-search.c. Makefile.local | 2 + notmuch-search.c | 304 ++++++++++++++--------------------------------- sprinter-json.c | 187 +++++++++++++++++++++++++++++ sprinter-text.c | 126 ++++++++++++++++++++ sprinter.h | 68 +++++++++++ test/json | 34 +++--- 6 files changed, 489 insertions(+), 232 deletions(-) create mode 100644 sprinter-json.c create mode 100644 sprinter-text.c create mode 100644 sprinter.h -- 1.7.11.2