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 A8986431FAE for ; Fri, 27 Jul 2012 21:29:26 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 sLQN313KXklS for ; Fri, 27 Jul 2012 21:29:25 -0700 (PDT) Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU [18.7.68.37]) by olra.theworths.org (Postfix) with ESMTP id 63907431FB6 for ; Fri, 27 Jul 2012 21:29:25 -0700 (PDT) X-AuditID: 12074425-b7f9b6d0000008c4-8f-50136aa4e5f9 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id 95.70.02244.4AA63105; Sat, 28 Jul 2012 00:29:24 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q6S4TNF4017242; Sat, 28 Jul 2012 00:29:23 -0400 Received: from drake.dyndns.org (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6S4TL3V027362 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 28 Jul 2012 00:29:22 -0400 (EDT) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1SuyeW-0002XD-T4; Sat, 28 Jul 2012 00:29:20 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 11/13] show: Convert show_message to use sprinter Date: Sat, 28 Jul 2012 00:29:12 -0400 Message-Id: <1343449754-9010-12-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1343449754-9010-1-git-send-email-amdragon@mit.edu> References: <1343449754-9010-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrAIsWRmVeSWpSXmKPExsUixCmqrLskSzjA4NtqbYu9De2MFqvn8lhc vzmT2eLNynmsDiweO2fdZfdYvGk/m8fhrwtZPJ6tusUcwBLFZZOSmpNZllqkb5fAlfHg3mWm gi6RimNrbrE1MD7l72Lk5JAQMJE4MOkPO4QtJnHh3nq2LkYuDiGBfYwSK86eYIZwNjBKnOhY AJV5xCTRu3wzI4Qzl1Fi2qc9rCD9bAIaEtv2L2cEsUUEpCV23p0NFOfgYBbIk3i8VgIkLCzg IrFo6mMWEJtFQFXiw7dVYK28Ag4St08fYoU4Q17i6f0+NhCbEyi++eUHZhBbSMBeYvfkDawT GPkXMDKsYpRNya3SzU3MzClOTdYtTk7My0st0rXQy80s0UtNKd3ECAo4dhfVHYwTDikdYhTg YFTi4T11RShAiDWxrLgy9xCjJAeTkihvVLhwgBBfUn5KZUZicUZ8UWlOavEhRgkOZiUR3p2C QDnelMTKqtSifJiUNAeLkjjvjZSb/kIC6YklqdmpqQWpRTBZGQ4OJQne7ZlAjYJFqempFWmZ OSUIaSYOTpDhPEDD14DU8BYXJOYWZ6ZD5E8xKkqJ804CSQiAJDJK8+B6YQnhFaM40CvCvNdA qniAyQSu+xXQYCagwRbRQiCDSxIRUlINjBUpeeurrh8M38qTGSb+rcy8Zlftyp079lz9JH2K d9Jzxh2cNk9fbfn0wP96wO6yKz/vcpbeXOmh/iE/4oYGR3jG/4U5fS9WMl5i141a25x1VWmb lWoyZ4H+P/0Hx0xmuRxvKZ38xid/8oNZz9I1v09q0bqf5zbDjbfmh7jJ0hk8m3b/fTpt5U8l luKMREMt5qLiRADlxulU4wIAAA== Cc: tomi.ollila@iki.fi 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, 28 Jul 2012 04:29:27 -0000 Unlike the previous patches, this function is used for all formats. However, for formats other than the JSON format, the sprinter methods used by show_message are all no-ops, so this code continues to function correctly for all of the formats. Converting show_message eliminates show_null_message in the process, since this maps directly to an sprinter method. --- notmuch-show.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index b9d9f5d..ec3e861 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -842,15 +842,6 @@ format_part_raw (unused (const void *ctx), unused (sprinter_t *sp), } 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, sprinter_t *sp, @@ -884,23 +875,16 @@ show_messages (void *ctx, notmuch_message_t *message; notmuch_bool_t match; notmuch_bool_t excluded; - int first_set = 1; int next_indent; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; - if (format->message_set_start) - fputs (format->message_set_start, stdout); + sp->begin_list (sp); for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { - if (!first_set && format->message_set_sep) - fputs (format->message_set_sep, stdout); - first_set = 0; - - if (format->message_set_start) - fputs (format->message_set_start, stdout); + sp->begin_list (sp); message = notmuch_messages_get (messages); @@ -915,12 +899,9 @@ show_messages (void *ctx, res = status; next_indent = indent + 1; } else { - status = show_null_message (format); + sp->null (sp); } - if (!status && format->message_set_sep) - fputs (format->message_set_sep, stdout); - status = show_messages (ctx, format, sp, notmuch_message_get_replies (message), @@ -931,12 +912,10 @@ show_messages (void *ctx, notmuch_message_destroy (message); - if (format->message_set_end) - fputs (format->message_set_end, stdout); + sp->end (sp); } - if (format->message_set_end) - fputs (format->message_set_end, stdout); + sp->end (sp); return res; } -- 1.7.10