1 Return-Path: <bremner@pivot.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id AB795431FCB
\r
6 for <notmuch@notmuchmail.org>; Sat, 19 Dec 2009 06:55:58 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id Fg4Cjt6SAjP0 for <notmuch@notmuchmail.org>;
\r
11 Sat, 19 Dec 2009 06:55:58 -0800 (PST)
\r
12 Received: from pivot.cs.unb.ca (pivot.cs.unb.ca [131.202.240.57])
\r
13 by olra.theworths.org (Postfix) with ESMTP id F222A431FC9
\r
14 for <notmuch@notmuchmail.org>; Sat, 19 Dec 2009 06:55:57 -0800 (PST)
\r
16 fctnnbsc30w-142167182194.pppoe-dynamic.high-speed.nb.bellaliant.net
\r
17 ([142.167.182.194] helo=localhost)
\r
18 by pivot.cs.unb.ca with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32)
\r
19 (Exim 4.69) (envelope-from <bremner@pivot.cs.unb.ca>)
\r
20 id 1NM0ir-0003aR-L3; Sat, 19 Dec 2009 10:55:57 -0400
\r
21 Received: from bremner by localhost with local (Exim 4.69)
\r
22 (envelope-from <bremner@pivot.cs.unb.ca>)
\r
23 id 1NM0im-0006eZ-7b; Sat, 19 Dec 2009 10:55:52 -0400
\r
24 From: david@tethera.net
\r
25 To: notmuch@notmuchmail.org
\r
26 Date: Sat, 19 Dec 2009 10:55:23 -0400
\r
27 Message-Id: <1261234524-25522-3-git-send-email-david@tethera.net>
\r
28 X-Mailer: git-send-email 1.6.5.3
\r
29 In-Reply-To: <1261234524-25522-2-git-send-email-david@tethera.net>
\r
30 References: <87iqc4yyo8.fsf@yoom.home.cworth.org>
\r
31 <1261234524-25522-1-git-send-email-david@tethera.net>
\r
32 <1261234524-25522-2-git-send-email-david@tethera.net>
\r
33 X-Sender-Verified: bremner@pivot.cs.unb.ca
\r
34 Cc: David Bremner <bremner@unb.ca>
\r
35 Subject: [notmuch] [PATCH 2/3] notmuch-show.c: make calls to format
\r
36 functions conditional
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.12
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Sat, 19 Dec 2009 14:55:58 -0000
\r
51 From: David Bremner <bremner@unb.ca>
\r
53 This makes it easier to define minimal formats without defining several
\r
54 dummy functions that do nothing.
\r
56 notmuch-show.c | 13 +++++++++----
\r
57 1 files changed, 9 insertions(+), 4 deletions(-)
\r
59 diff --git a/notmuch-show.c b/notmuch-show.c
\r
60 index b6e3f44..51aa87d 100644
\r
61 --- a/notmuch-show.c
\r
62 +++ b/notmuch-show.c
\r
63 @@ -326,14 +326,17 @@ static void
\r
64 show_message (void *ctx, const show_format_t *format, notmuch_message_t *message, int indent)
\r
66 fputs (format->message_start, stdout);
\r
67 - format->message(ctx, message, indent);
\r
68 + if (format->message)
\r
69 + format->message(ctx, message, indent);
\r
71 fputs (format->header_start, stdout);
\r
72 - format->header(ctx, message);
\r
73 + if (format->header)
\r
74 + format->header(ctx, message);
\r
75 fputs (format->header_end, stdout);
\r
77 fputs (format->body_start, stdout);
\r
78 - show_message_body (notmuch_message_get_filename (message), format->part);
\r
79 + if (format->part)
\r
80 + show_message_body (notmuch_message_get_filename (message), format->part);
\r
81 fputs (format->body_end, stdout);
\r
83 fputs (format->message_end, stdout);
\r
84 @@ -408,7 +411,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
\r
86 if (STRNCMP_LITERAL (argv[i], "--format=") == 0) {
\r
87 opt = argv[i] + sizeof ("--format=") - 1;
\r
88 - if (strcmp (opt, "text") == 0) {
\r
89 + if (strcmp (opt, "tabular") == 0) {
\r
90 + format = &format_tabular;
\r
91 + } else if (strcmp (opt, "text") == 0) {
\r
92 format = &format_text;
\r
93 } else if (strcmp (opt, "json") == 0) {
\r
94 format = &format_json;
\r