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 BCB1E49F194 for ; Thu, 11 Mar 2010 04:12:08 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.81 X-Spam-Level: X-Spam-Status: No, score=-0.81 tagged_above=-999 required=5 tests=[AWL=-0.070, BAYES_20=-0.74] 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 pk0wQQvwPJWp for ; Thu, 11 Mar 2010 04:12:08 -0800 (PST) Received: from homiemail-a22.g.dreamhost.com (caiajhbdccac.dreamhost.com [208.97.132.202]) by olra.theworths.org (Postfix) with ESMTP id EE2DF49F191 for ; Thu, 11 Mar 2010 04:12:07 -0800 (PST) Received: from localhost.localdomain (unknown [84.55.211.9]) by homiemail-a22.g.dreamhost.com (Postfix) with ESMTPA id 3776F1A805F; Thu, 11 Mar 2010 04:11:48 -0800 (PST) From: Sebastian Spaeth To: notmuch@notmuchmail.org Date: Thu, 11 Mar 2010 13:11:43 +0100 Message-Id: <1268309504-4211-1-git-send-email-Sebastian@SSpaeth.de> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <87vdd4zf6p.fsf@SSpaeth.de> References: <87vdd4zf6p.fsf@SSpaeth.de> Subject: [notmuch] [PATCH] 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: Thu, 11 Mar 2010 12:12:08 -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 notmuch tags as a json array. 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..bf9e022 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_valid (tags); + notmuch_tags_move_to_next (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