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 8257A431FC3 for ; Tue, 2 Mar 2010 02:52:53 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.94 X-Spam-Level: X-Spam-Status: No, score=-1.94 tagged_above=-999 required=5 tests=[AWL=0.659, BAYES_00=-2.599] autolearn=ham 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 8h-XGc53WTJq for ; Tue, 2 Mar 2010 02:52:52 -0800 (PST) Received: from homiemail-a13.g.dreamhost.com (caiajhbdccah.dreamhost.com [208.97.132.207]) by olra.theworths.org (Postfix) with ESMTP id F0798431FC4 for ; Tue, 2 Mar 2010 02:52:50 -0800 (PST) Received: from localhost.localdomain (mtec-hg-docking-1-dhcp-204.ethz.ch [129.132.133.204]) by homiemail-a13.g.dreamhost.com (Postfix) with ESMTPA id 799F46A8073; Tue, 2 Mar 2010 02:52:41 -0800 (PST) From: Sebastian Spaeth To: notmuch@notmuchmail.org Date: Tue, 2 Mar 2010 11:52:33 +0100 Message-Id: <1267527153-8364-2-git-send-email-Sebastian@SSpaeth.de> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1267527153-8364-1-git-send-email-Sebastian@SSpaeth.de> References: <87k4twc5dh.fsf@servo.finestructure.net> <1267527153-8364-1-git-send-email-Sebastian@SSpaeth.de> Subject: [notmuch] [PATCH 2/2] notmuch-show: add tags to json output 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: Tue, 02 Mar 2010 10:52:53 -0000 The previous json patches forgot to add the notmuch tags to the json output. This is inconsistent to the text output so here they are. We just output a 'tags' field that sends a space delimited list of json-encoded notmuch tags. Signed-off-by: Sebastian Spaeth --- notmuch-show.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index f21914f..d3a4e9f 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -136,13 +136,24 @@ format_message_text (unused (const void *ctx), notmuch_message_t *message, int i static void format_message_json (const void *ctx, notmuch_message_t *message, unused (int indent)) { + notmuch_tags_t *tags; + int first = 1; void *ctx_quote = talloc_new (ctx); - printf ("\"id\": %s, \"match\": %s, \"filename\": %s", + printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"tags\": [", json_quote_str (ctx_quote, notmuch_message_get_message_id (message)), notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? "true" : "false", json_quote_str (ctx_quote, notmuch_message_get_filename (message))); + for (tags = notmuch_message_get_tags (message); + notmuch_tags_has_more (tags); + notmuch_tags_advance (tags)) + { + printf("%s%s", first ? "" : ",", + json_quote_str (ctx_quote, notmuch_tags_get (tags))); + first = 0; + } + printf("]"); talloc_free (ctx_quote); } -- 1.6.3.3