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 AB795431FCB for ; Sat, 19 Dec 2009 06:55:58 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 Fg4Cjt6SAjP0 for ; Sat, 19 Dec 2009 06:55:58 -0800 (PST) Received: from pivot.cs.unb.ca (pivot.cs.unb.ca [131.202.240.57]) by olra.theworths.org (Postfix) with ESMTP id F222A431FC9 for ; Sat, 19 Dec 2009 06:55:57 -0800 (PST) Received: from fctnnbsc30w-142167182194.pppoe-dynamic.high-speed.nb.bellaliant.net ([142.167.182.194] helo=localhost) by pivot.cs.unb.ca with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1NM0ir-0003aR-L3; Sat, 19 Dec 2009 10:55:57 -0400 Received: from bremner by localhost with local (Exim 4.69) (envelope-from ) id 1NM0im-0006eZ-7b; Sat, 19 Dec 2009 10:55:52 -0400 From: david@tethera.net To: notmuch@notmuchmail.org Date: Sat, 19 Dec 2009 10:55:23 -0400 Message-Id: <1261234524-25522-3-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.6.5.3 In-Reply-To: <1261234524-25522-2-git-send-email-david@tethera.net> References: <87iqc4yyo8.fsf@yoom.home.cworth.org> <1261234524-25522-1-git-send-email-david@tethera.net> <1261234524-25522-2-git-send-email-david@tethera.net> X-Sender-Verified: bremner@pivot.cs.unb.ca Cc: David Bremner Subject: [notmuch] [PATCH 2/3] notmuch-show.c: make calls to format functions conditional X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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, 19 Dec 2009 14:55:58 -0000 From: David Bremner This makes it easier to define minimal formats without defining several dummy functions that do nothing. --- notmuch-show.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index b6e3f44..51aa87d 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -326,14 +326,17 @@ static void show_message (void *ctx, const show_format_t *format, notmuch_message_t *message, int indent) { fputs (format->message_start, stdout); - format->message(ctx, message, indent); + if (format->message) + format->message(ctx, message, indent); fputs (format->header_start, stdout); - format->header(ctx, message); + if (format->header) + format->header(ctx, message); fputs (format->header_end, stdout); fputs (format->body_start, stdout); - show_message_body (notmuch_message_get_filename (message), format->part); + if (format->part) + show_message_body (notmuch_message_get_filename (message), format->part); fputs (format->body_end, stdout); fputs (format->message_end, stdout); @@ -408,7 +411,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) } if (STRNCMP_LITERAL (argv[i], "--format=") == 0) { opt = argv[i] + sizeof ("--format=") - 1; - if (strcmp (opt, "text") == 0) { + if (strcmp (opt, "tabular") == 0) { + format = &format_tabular; + } else if (strcmp (opt, "text") == 0) { format = &format_text; } else if (strcmp (opt, "json") == 0) { format = &format_json; -- 1.6.5.3