unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 1/3] notmuch: Include the format parameter of text/plain parts
Date: Sat, 22 Dec 2018 12:10:56 +0000	[thread overview]
Message-ID: <20181222121058.5892-2-dme@dme.org> (raw)
In-Reply-To: <20181222121058.5892-1-dme@dme.org>

During formatted output, if a content type of a text/plain part
has a "format" paramter, include it in the output.
---
 devel/schemata |  2 ++
 notmuch-show.c | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/devel/schemata b/devel/schemata
index 42b1bcf3..194933d4 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -93,6 +93,8 @@ part = {
     # otherwise (leaf parts):
     filename?:      string,
     content-charset?: string,
+    # if content-type is "text/plain" and a "format" parameter exists:
+    format?:        string,
     # A leaf part's body content is optional, but may be included if
     # it can be correctly encoded as a string.  Consumers should use
     # this in preference to fetching the part content separately.
diff --git a/notmuch-show.c b/notmuch-show.c
index 07e9a5db..92d18bb8 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -708,6 +708,19 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
     }
 
     if (GMIME_IS_PART (node->part)) {
+	/* Include the format parameter of text/plain parts if it
+	 * exists, allowing the UI to adapt the display of the part as
+	 * appropriate.
+	 */
+	if (g_mime_content_type_is_type (content_type, "text", "plain")) {
+	    const char *format =
+		g_mime_object_get_content_type_parameter (node->part, "format");
+	    if (format) {
+		sp->map_key (sp, "format");
+		sp->string (sp, format);
+	    }
+	}
+
 	/* For non-HTML text parts, we include the content in the
 	 * JSON. Since JSON must be Unicode, we handle charset
 	 * decoding here and do not report a charset to the caller.
-- 
2.11.0

  reply	other threads:[~2018-12-22 12:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-22 12:10 [PATCH v2 0/3] support for format=flowed text display David Edmondson
2018-12-22 12:10 ` David Edmondson [this message]
2018-12-22 12:10 ` [PATCH v2 2/3] emacs: Pass the part to text/plain hook functions David Edmondson
2019-03-28 17:58   ` David Bremner
2018-12-22 12:10 ` [PATCH v2 3/3] emacs: Process format=flowed text David Edmondson
2020-05-30 20:49   ` Jed Brown
2020-05-31 11:47     ` David Bremner
2020-06-01  0:11       ` Jed Brown

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=20181222121058.5892-2-dme@dme.org \
    --to=dme@dme.org \
    --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).