From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Cc: Damien Cassou <damien@cassou.me>, jani@nikula.org
Subject: [REBASED RFC PATCH] cli/show: include content type parameters in formatted output
Date: Sun, 5 Mar 2017 13:17:05 +0200 [thread overview]
Message-ID: <20170305111705.6449-1-jani@nikula.org> (raw)
In-Reply-To: <20170222214058.26209-1-jani@nikula.org>
This is primarily to be able to handle "text/plain; format=flowed",
but I don't see much point in making this specific to
format=flowed. Just include all content type parameters in the
formatted output, like this:
"content-type" : "text/plain",
"content-type-params" : [
{
"format" : "flowed"
}
],
It might make sense to change the content-type key in schemata to
include the parameters in a more structured fashion instead of adding
a separate key like here, but this doesn't require a change in
consumers or schemata version bump.
This was just a quick proof of concept, and obviously lacks tests,
schemata updates, etc.
---
notmuch-show.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/notmuch-show.c b/notmuch-show.c
index 744b62727c26..866b974fcefa 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -625,6 +625,19 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
sp->map_key (sp, "content-type");
sp->string (sp, g_mime_content_type_to_string (content_type));
+ const GMimeParam *params = g_mime_content_type_get_params (content_type);
+ if (params) {
+ sp->map_key (sp, "content-type-params");
+ sp->begin_list (sp);
+ sp->begin_map (sp);
+ for (; params; params = params->next) {
+ sp->map_key (sp, params->name);
+ sp->string (sp, params->value);
+ }
+ sp->end (sp);
+ sp->end (sp);
+ }
+
if (disposition) {
sp->map_key (sp, "content-disposition");
sp->string (sp, disposition);
--
2.11.0
prev parent reply other threads:[~2017-03-05 11:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-22 21:40 [RFC PATCH] cli/show: include content type parameters in formatted output Jani Nikula
2017-03-05 11:17 ` Jani Nikula [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170305111705.6449-1-jani@nikula.org \
--to=jani@nikula.org \
--cc=damien@cassou.me \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).