Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / cb / cb11299bbd1fad804d3f16dc647b8411ef716b
1 Return-Path: <jani@nikula.org>\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 14FDF431FAF\r
6         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 14:33:52 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id aiZbKcWIU7T4 for <notmuch@notmuchmail.org>;\r
16         Wed, 18 Jan 2012 14:33:51 -0800 (PST)\r
17 Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
18  [74.125.83.53])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  5DB56431FAE    for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 14:33:51 -0800\r
21  (PST)\r
22 Received: by eeke51 with SMTP id e51so871796eek.26\r
23         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 14:33:50 -0800 (PST)\r
24 Received: by 10.14.11.97 with SMTP id 73mr798254eew.2.1326926030107;\r
25         Wed, 18 Jan 2012 14:33:50 -0800 (PST)\r
26 Received: from localhost (dsl-hkibrasgw4-fe50f800-253.dhcp.inet.fi.\r
27         [84.248.80.253])\r
28         by mx.google.com with ESMTPS id e12sm105243459eea.5.2012.01.18.14.33.46\r
29         (version=SSLv3 cipher=OTHER); Wed, 18 Jan 2012 14:33:49 -0800 (PST)\r
30 From: Jani Nikula <jani@nikula.org>\r
31 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
32 Subject: Re: [PATCH 3/3] show: Introduce mime_node formatter callback\r
33 In-Reply-To: <1326918507-28033-4-git-send-email-amdragon@mit.edu>\r
34 References: <1326918507-28033-1-git-send-email-amdragon@mit.edu>\r
35         <1326918507-28033-4-git-send-email-amdragon@mit.edu>\r
36 User-Agent: Notmuch/0.11+76~g1de742d (http://notmuchmail.org) Emacs/23.3.1\r
37         (i686-pc-linux-gnu)\r
38 Date: Thu, 19 Jan 2012 00:33:44 +0200\r
39 Message-ID: <87wr8obpyv.fsf@nikula.org>\r
40 MIME-Version: 1.0\r
41 Content-Type: text/plain; charset=us-ascii\r
42 Cc: dkg@fifthhorseman.net\r
43 X-BeenThere: notmuch@notmuchmail.org\r
44 X-Mailman-Version: 2.1.13\r
45 Precedence: list\r
46 List-Id: "Use and development of the notmuch mail system."\r
47         <notmuch.notmuchmail.org>\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
51 List-Post: <mailto:notmuch@notmuchmail.org>\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
55 X-List-Received-Date: Wed, 18 Jan 2012 22:33:52 -0000\r
56 \r
57 On Wed, 18 Jan 2012 15:28:27 -0500, Austin Clements <amdragon@MIT.EDU> wrote:\r
58 > This callback is the gateway to the new mime_node_t-based formatters.\r
59 > This maintains backwards compatibility so the formatters can be\r
60 > transitioned one at a time.  Once all formatters are converted, the\r
61 > formatter structure can be reduced to only message_set_{start,sep,end}\r
62 > and part, most of show_message can be deleted, and all of\r
63 > show-message.c can be deleted.\r
64 > ---\r
65 >  notmuch-client.h |    6 ++++++\r
66 >  notmuch-reply.c  |    2 +-\r
67 >  notmuch-show.c   |   22 ++++++++++++++++++----\r
68 >  3 files changed, 25 insertions(+), 5 deletions(-)\r
69\r
70 > diff --git a/notmuch-client.h b/notmuch-client.h\r
71 > index b3dcb6b..3ccdfad 100644\r
72 > --- a/notmuch-client.h\r
73 > +++ b/notmuch-client.h\r
74 > @@ -54,8 +54,14 @@\r
75 >  #define STRINGIFY(s) STRINGIFY_(s)\r
76 >  #define STRINGIFY_(s) #s\r
77 >  \r
78 > +struct mime_node;\r
79 > +struct notmuch_show_params;\r
80 > +\r
81 >  typedef struct notmuch_show_format {\r
82 >      const char *message_set_start;\r
83 > +    void (*part) (const void *ctx,\r
84 > +               struct mime_node *node, int indent,\r
85 > +               struct notmuch_show_params *params);\r
86 >      const char *message_start;\r
87 >      void (*message) (const void *ctx,\r
88 >                    notmuch_message_t *message,\r
89 > diff --git a/notmuch-reply.c b/notmuch-reply.c\r
90 > index 0f682db..9a224e2 100644\r
91 > --- a/notmuch-reply.c\r
92 > +++ b/notmuch-reply.c\r
93 > @@ -31,7 +31,7 @@ static void\r
94 >  reply_part_content (GMimeObject *part);\r
95 >  \r
96 >  static const notmuch_show_format_t format_reply = {\r
97 > -    "",\r
98 > +    "", NULL,\r
99 >       "", NULL,\r
100 >           "", NULL, reply_headers_message_part, ">\n",\r
101 >           "",\r
102 > diff --git a/notmuch-show.c b/notmuch-show.c\r
103 > index ecadfa8..46eef44 100644\r
104 > --- a/notmuch-show.c\r
105 > +++ b/notmuch-show.c\r
106 > @@ -42,7 +42,7 @@ static void\r
107 >  format_part_end_text (GMimeObject *part);\r
108 >  \r
109 >  static const notmuch_show_format_t format_text = {\r
110 > -    "",\r
111 > +    "", NULL,\r
112 >       "\fmessage{ ", format_message_text,\r
113 >           "\fheader{\n", format_headers_text, format_headers_message_part_text, "\fheader}\n",\r
114 >           "\fbody{\n",\r
115 > @@ -85,7 +85,7 @@ static void\r
116 >  format_part_end_json (GMimeObject *part);\r
117 >  \r
118 >  static const notmuch_show_format_t format_json = {\r
119 > -    "[",\r
120 > +    "[", NULL,\r
121 >       "{", format_message_json,\r
122 >           "\"headers\": {", format_headers_json, format_headers_message_part_json, "}",\r
123 >           ", \"body\": [",\r
124 > @@ -106,7 +106,7 @@ format_message_mbox (const void *ctx,\r
125 >                    unused (int indent));\r
126 >  \r
127 >  static const notmuch_show_format_t format_mbox = {\r
128 > -    "",\r
129 > +    "", NULL,\r
130 >          "", format_message_mbox,\r
131 >              "", NULL, NULL, "",\r
132 >              "",\r
133 > @@ -125,7 +125,7 @@ static void\r
134 >  format_part_content_raw (GMimeObject *part);\r
135 >  \r
136 >  static const notmuch_show_format_t format_raw = {\r
137 > -    "",\r
138 > +    "", NULL,\r
139 >       "", NULL,\r
140 >           "", NULL, format_headers_message_part_text, "\n",\r
141 >              "",\r
142 > @@ -762,6 +762,20 @@ show_message (void *ctx,\r
143 >             int indent,\r
144 >             notmuch_show_params_t *params)\r
145 >  {\r
146 > +    if (format->part) {\r
147 > +     void *local = talloc_new (ctx);\r
148 > +     mime_node_t *root, *part;\r
149 > +\r
150 > +     if (mime_node_open (local, message, params->cryptoctx, params->decrypt,\r
151 > +                         &root) != NOTMUCH_STATUS_SUCCESS)\r
152 \r
153 I'm new to talloc, I think I like it, but I always find it confusing\r
154 when some code paths free the contexts, and some don't. Like here.\r
155 \r
156 Are you not freeing the local context here because it's just an empty\r
157 context, and freeing below because it's no longer empty?\r
158 \r
159 No need to change anything, I guess, just asking...\r
160 \r
161 BR,\r
162 Jani.\r
163 \r
164 > +         return;\r
165 > +     part = mime_node_seek_dfs (root, params->part < 0 ? 0 : params->part);\r
166 > +     if (part)\r
167 > +         format->part (local, part, indent, params);\r
168 > +     talloc_free (local);\r
169 > +     return;\r
170 > +    }\r
171 > +\r
172 >      if (params->part <= 0) {\r
173 >       fputs (format->message_start, stdout);\r
174 >       if (format->message)\r
175 > -- \r
176 > 1.7.7.3\r
177\r