From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 45400431FD5 for ; Sat, 16 Jun 2012 03:22:11 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 3NYGGMIrD0OB for ; Sat, 16 Jun 2012 03:22:10 -0700 (PDT) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id B2B3D431FAE for ; Sat, 16 Jun 2012 03:22:06 -0700 (PDT) Received: by wibhn14 with SMTP id hn14so274152wib.2 for ; Sat, 16 Jun 2012 03:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=sjxiZsreiuCKMKlBPdFWEvcVVRkdrqNqkryzeF3oElI=; b=P0bvWSm+lGKUMr8ZpE03pQCZk/v4miVumBpMRaoxIEVfnmghK2e0FtIBenaZJRh8Ko +0eC0mY4WMfxAt9O9kUu9T/xAMltc5KYRYNYVj0yisWDpsBO72mbLF19CSRDWJGAp2cR TcrnNW3RwoFqIVKy7pD2pMKgFEJmC8E4DuEMH9auy6Dw84bNEYqd391rlR+d8t5OCOFX htudWdg++sNuAWM8J2SnMKMNzh2esBy7gY24injg45y4ZH0vxzYeUoxwuqgdBBT4h2Bx bzaUgZDsNwHY5oiXQNHSGv7/2ITVqL40YeGnNm/cWzDdpdzV/Re0F6/oUG5dT8tYTuXG BRVA== Received: by 10.180.95.137 with SMTP id dk9mr10643314wib.1.1339842125377; Sat, 16 Jun 2012 03:22:05 -0700 (PDT) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id ez4sm9560425wid.3.2012.06.16.03.22.04 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 16 Jun 2012 03:22:04 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [Patch v8 2/6] cli: Let json output "null" messages for non --entire-thread Date: Sat, 16 Jun 2012 11:21:43 +0100 Message-Id: <1339842107-10632-3-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1339842107-10632-1-git-send-email-markwalters1009@gmail.com> References: <1339842107-10632-1-git-send-email-markwalters1009@gmail.com> 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: Sat, 16 Jun 2012 10:22:11 -0000 All formats except Json can output empty messages for non entire-thread, but in Json format we output "null" to keep the other elements (e.g. the replies to the omitted message) in the correct place. --- notmuch-client.h | 1 + notmuch-show.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index 9b63eae..0c17b79 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -75,6 +75,7 @@ typedef struct notmuch_show_format { const struct notmuch_show_params *params); const char *message_set_sep; const char *message_set_end; + const char *null_message; } notmuch_show_format_t; typedef struct notmuch_crypto { diff --git a/notmuch-show.c b/notmuch-show.c index 8247f1d..b004468 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -37,7 +37,8 @@ static const notmuch_show_format_t format_json = { .message_set_start = "[", .part = format_part_json_entry, .message_set_sep = ", ", - .message_set_end = "]" + .message_set_end = "]", + .null_message = "null" }; static notmuch_status_t @@ -800,6 +801,15 @@ format_part_raw (unused (const void *ctx), mime_node_t *node, } static notmuch_status_t +show_null_message (const notmuch_show_format_t *format) +{ + /* Output a null message. Currently empty for all formats except Json */ + if (format->null_message) + printf ("%s", format->null_message); + return NOTMUCH_STATUS_SUCCESS; +} + +static notmuch_status_t show_message (void *ctx, const notmuch_show_format_t *format, notmuch_message_t *message, @@ -861,11 +871,13 @@ show_messages (void *ctx, if (status && !res) res = status; next_indent = indent + 1; - - if (!status && format->message_set_sep) - fputs (format->message_set_sep, stdout); + } else { + status = show_null_message (format); } + if (!status && format->message_set_sep) + fputs (format->message_set_sep, stdout); + status = show_messages (ctx, format, notmuch_message_get_replies (message), -- 1.7.9.1