Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 6c / d1674991c9088fe790d69aa9cb34a427ca98cc
1 Return-Path: <amthrax@drake.mit.edu>\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 5DFFB421188\r
6         for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 18:31:24 -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 oAEPcM7X8mjF for <notmuch@notmuchmail.org>;\r
16         Sun, 22 Jan 2012 18:31:23 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU\r
18         [18.9.25.13])\r
19         by olra.theworths.org (Postfix) with ESMTP id E95E8429E5F\r
20         for <notmuch@notmuchmail.org>; Sun, 22 Jan 2012 18:31:22 -0800 (PST)\r
21 X-AuditID: 1209190d-b7fbf6d0000008ba-9d-4f1cc67ae5e8\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id E6.EB.02234.A76CC1F4; Sun, 22 Jan 2012 21:31:22 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q0N2VMI1017753; \r
27         Sun, 22 Jan 2012 21:31:22 -0500\r
28 Received: from drake.mit.edu\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q0N2VLvc001255\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sun, 22 Jan 2012 21:31:21 -0500 (EST)\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
36         (envelope-from <amthrax@drake.mit.edu>)\r
37         id 1Rp9gm-0001J9-T5; Sun, 22 Jan 2012 21:31:20 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v2 3/3] show: Introduce mime_node formatter callback\r
41 Date: Sun, 22 Jan 2012 21:31:13 -0500\r
42 Message-Id: <1327285873-4713-4-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.7.3\r
44 In-Reply-To: <1327285873-4713-1-git-send-email-amdragon@mit.edu>\r
45 References: <1326918507-28033-1-git-send-email-amdragon@mit.edu>\r
46         <1327285873-4713-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrVt1TMbfoO2vtMX1mzOZHRg9nq26\r
49         xRzAGMVlk5Kak1mWWqRvl8CV8XPdWfaC+VIVX7a+Zm5g3CjSxcjJISFgItF3+h0ThC0mceHe\r
50         ejYQW0hgH6PEoxbNLkYuIHsDo8SVhwcZIZz7TBLb/h1lhnDmM0osXPaHHaSFTUBDYtv+5Ywg\r
51         toiAtMTOu7NZuxg5OJgF1CT+dKmAhIUFXCS+z53OBBJmEVCVaNyeAxLmFbCX6D21mBXiCAWJ\r
52         c6vPgU3kFHCQ2H3pBCPEQWUS969OYJzAyL+AkWEVo2xKbpVubmJmTnFqsm5xcmJeXmqRrpFe\r
53         bmaJXmpK6SZGcMhI8u5gfHdQ6RCjAAejEg9vxFIZfyHWxLLiytxDjJIcTEqivGZHgUJ8Sfkp\r
54         lRmJxRnxRaU5qcWHGCU4mJVEeJ0/S/sL8aYkVlalFuXDpKQ5WJTEeVW13vkJCaQnlqRmp6YW\r
55         pBbBZGU4OJQkeL+CDBUsSk1PrUjLzClBSDNxcIIM5wEa/gikhre4IDG3ODMdIn+KUVFKnPcv\r
56         SEIAJJFRmgfXC4vpV4ziQK8I8z4BqeIBpgO47ldAg5mABnPkSYEMLklESEk1MB4u953wvWv5\r
57         xT626QqMR7e6q/RbfHkvdTzSSi1+Pof6+elqF5KOb+5fJsO8e89XVy7tLyGd6g+236v3Up2y\r
58         bdrH1ItB+c0m10/8SN+3OfDuMv5XU49Jn+2KmvRB7JKyss2kldOP7avePUlHe8WcVcdeLMr7\r
59         lhZ8fUfe4qoj4YsZbKx0lzS/UF6sxFKckWioxVxUnAgA161OV8QCAAA=\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Mon, 23 Jan 2012 02:31:24 -0000\r
73 \r
74 This callback is the gateway to the new mime_node_t-based formatters.\r
75 This maintains backwards compatibility so the formatters can be\r
76 transitioned one at a time.  Once all formatters are converted, the\r
77 formatter structure can be reduced to only message_set_{start,sep,end}\r
78 and part, most of show_message can be deleted, and all of\r
79 show-message.c can be deleted.\r
80 ---\r
81  notmuch-client.h |    6 ++++++\r
82  notmuch-reply.c  |    2 +-\r
83  notmuch-show.c   |   23 +++++++++++++++++++----\r
84  3 files changed, 26 insertions(+), 5 deletions(-)\r
85 \r
86 diff --git a/notmuch-client.h b/notmuch-client.h\r
87 index abfe5d3..59606b4 100644\r
88 --- a/notmuch-client.h\r
89 +++ b/notmuch-client.h\r
90 @@ -62,8 +62,14 @@\r
91  #define STRINGIFY(s) STRINGIFY_(s)\r
92  #define STRINGIFY_(s) #s\r
93  \r
94 +struct mime_node;\r
95 +struct notmuch_show_params;\r
96 +\r
97  typedef struct notmuch_show_format {\r
98      const char *message_set_start;\r
99 +    void (*part) (const void *ctx,\r
100 +                 struct mime_node *node, int indent,\r
101 +                 struct notmuch_show_params *params);\r
102      const char *message_start;\r
103      void (*message) (const void *ctx,\r
104                      notmuch_message_t *message,\r
105 diff --git a/notmuch-reply.c b/notmuch-reply.c\r
106 index bf67960..f55b1d2 100644\r
107 --- a/notmuch-reply.c\r
108 +++ b/notmuch-reply.c\r
109 @@ -31,7 +31,7 @@ static void\r
110  reply_part_content (GMimeObject *part);\r
111  \r
112  static const notmuch_show_format_t format_reply = {\r
113 -    "",\r
114 +    "", NULL,\r
115         "", NULL,\r
116             "", NULL, reply_headers_message_part, ">\n",\r
117             "",\r
118 diff --git a/notmuch-show.c b/notmuch-show.c\r
119 index 682aa71..8185b02 100644\r
120 --- a/notmuch-show.c\r
121 +++ b/notmuch-show.c\r
122 @@ -42,7 +42,7 @@ static void\r
123  format_part_end_text (GMimeObject *part);\r
124  \r
125  static const notmuch_show_format_t format_text = {\r
126 -    "",\r
127 +    "", NULL,\r
128         "\fmessage{ ", format_message_text,\r
129             "\fheader{\n", format_headers_text, format_headers_message_part_text, "\fheader}\n",\r
130             "\fbody{\n",\r
131 @@ -89,7 +89,7 @@ static void\r
132  format_part_end_json (GMimeObject *part);\r
133  \r
134  static const notmuch_show_format_t format_json = {\r
135 -    "[",\r
136 +    "[", NULL,\r
137         "{", format_message_json,\r
138             "\"headers\": {", format_headers_json, format_headers_message_part_json, "}",\r
139             ", \"body\": [",\r
140 @@ -110,7 +110,7 @@ format_message_mbox (const void *ctx,\r
141                      unused (int indent));\r
142  \r
143  static const notmuch_show_format_t format_mbox = {\r
144 -    "",\r
145 +    "", NULL,\r
146          "", format_message_mbox,\r
147              "", NULL, NULL, "",\r
148              "",\r
149 @@ -129,7 +129,7 @@ static void\r
150  format_part_content_raw (GMimeObject *part);\r
151  \r
152  static const notmuch_show_format_t format_raw = {\r
153 -    "",\r
154 +    "", NULL,\r
155         "", NULL,\r
156             "", NULL, format_headers_message_part_text, "\n",\r
157              "",\r
158 @@ -850,6 +850,21 @@ show_message (void *ctx,\r
159               int indent,\r
160               notmuch_show_params_t *params)\r
161  {\r
162 +    if (format->part) {\r
163 +       void *local = talloc_new (ctx);\r
164 +       mime_node_t *root, *part;\r
165 +\r
166 +       if (mime_node_open (local, message, params->cryptoctx, params->decrypt,\r
167 +                           &root) != NOTMUCH_STATUS_SUCCESS)\r
168 +           goto DONE;\r
169 +       part = mime_node_seek_dfs (root, params->part < 0 ? 0 : params->part);\r
170 +       if (part)\r
171 +           format->part (local, part, indent, params);\r
172 +      DONE:\r
173 +       talloc_free (local);\r
174 +       return;\r
175 +    }\r
176 +\r
177      if (params->part <= 0) {\r
178         fputs (format->message_start, stdout);\r
179         if (format->message)\r
180 -- \r
181 1.7.7.3\r
182 \r