From 43acee4219b85cbc045c11ce464018fcb3af5c3e Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 3 Jun 2012 12:46:08 +0100 Subject: [PATCH] [Patch v7 2/6] cli: Let json output "null" messages for non --entire-thread --- d1/805e732cc1addd438c33a8e97822d65fe92c23 | 134 ++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 d1/805e732cc1addd438c33a8e97822d65fe92c23 diff --git a/d1/805e732cc1addd438c33a8e97822d65fe92c23 b/d1/805e732cc1addd438c33a8e97822d65fe92c23 new file mode 100644 index 000000000..e8a512ff6 --- /dev/null +++ b/d1/805e732cc1addd438c33a8e97822d65fe92c23 @@ -0,0 +1,134 @@ +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 550F1431FBC + for ; Sun, 3 Jun 2012 04:46:23 -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 qxR40xpQQovq for ; + Sun, 3 Jun 2012 04:46:21 -0700 (PDT) +Received: from mail-we0-f181.google.com (mail-we0-f181.google.com + [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 1D9B0431FB6 + for ; Sun, 3 Jun 2012 04:46:20 -0700 (PDT) +Received: by mail-we0-f181.google.com with SMTP id j55so2729830wer.26 + for ; Sun, 03 Jun 2012 04:46:20 -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=mfd1W0o3Zq5XgbruG4RMp4PSq5smW6eg4We84NNSXOc=; + b=E75Se4CE1Kozd9iNc6LWmi5+mZVoQvmunTPpzFN5ks+dCHUdmc49fJqZA8G2udTQlC + anfcZZUmqtcqvYlwQxkoL8aemxz0kiBESqlqaC9RPeH2C/D5vGkz7J6+uPsjhYNTpoAs + YjBkUfefsAQFx6grgxwAF82/4FOBrifxBpihNOQiaYxht4sYJdbZw/b03o9rqaEIeps9 + j9kkay+ta4/XAFfvwG00prOR/7q0OD8r3Gc+8Mxj9unjcMSWkhCp0q/K19+O2cqyceE3 + pd+BNnf/6Dvrfwo8Txa/ZhldAyNaFqii7sg8n/IgjXRL7D+HbMil26qQ764gQ3n+6AOn + zqcQ== +Received: by 10.216.208.31 with SMTP id p31mr7564405weo.134.1338723980755; + Sun, 03 Jun 2012 04:46:20 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + z8sm19485947wiy.1.2012.06.03.04.46.19 (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 03 Jun 2012 04:46:20 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [Patch v7 2/6] cli: Let json output "null" messages for non + --entire-thread +Date: Sun, 3 Jun 2012 12:46:08 +0100 +Message-Id: <1338723972-13063-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1338723972-13063-1-git-send-email-markwalters1009@gmail.com> +References: <1338723972-13063-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: Sun, 03 Jun 2012 11:46:23 -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 19b7f01..08540a7 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -72,6 +72,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_show_params { +diff --git a/notmuch-show.c b/notmuch-show.c +index 95427d4..97da5cc 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, +@@ -862,11 +872,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 + -- 2.26.2