unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH] notmuch/emacs: Observe the charset of encoded parts, where known.
Date: Wed, 11 Jan 2012 10:50:01 +0000	[thread overview]
Message-ID: <1326279001-28427-1-git-send-email-dme@dme.org> (raw)

Add the charset of encoded parts to the JSON output of 'notmuch -show'
when it is known. Observe the encoding when rendering parts in emacs.
---

Domo_ discovered that w3m was being called with an incorrect charset
to render text/html parts. This fixes that.

 emacs/notmuch-show.el |    3 ++-
 notmuch-show.c        |    3 +++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..0354a8e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -328,7 +328,8 @@ message at DEPTH in the current thread."
 current buffer, if possible."
   (let ((display-buffer (current-buffer)))
     (with-temp-buffer
-      (let ((handle (mm-make-handle (current-buffer) (list content-type))))
+      (let* ((charset (plist-get part :content-charset))
+	     (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))
 	(if (and (mm-inlinable-p handle)
 		 (mm-inlined-p handle))
 	    (let ((content (notmuch-show-get-bodypart-content msg part nth)))
diff --git a/notmuch-show.c b/notmuch-show.c
index 0200b9c..3c9c610 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -657,6 +657,7 @@ static void
 format_part_content_json (GMimeObject *part)
 {
     GMimeContentType *content_type = g_mime_object_get_content_type (GMIME_OBJECT (part));
+    const char *content_charset = g_mime_object_get_content_type_parameter (GMIME_OBJECT (part), "charset");
     GMimeStream *stream_memory = g_mime_stream_mem_new ();
     const char *cid = g_mime_object_get_content_id (part);
     void *ctx = talloc_new (NULL);
@@ -664,6 +665,8 @@ format_part_content_json (GMimeObject *part)
 
     printf (", \"content-type\": %s",
 	    json_quote_str (ctx, g_mime_content_type_to_string (content_type)));
+    if (content_charset != NULL)
+	printf (", \"content-charset\": %s", json_quote_str (ctx, content_charset));
 
     if (cid != NULL)
 	    printf(", \"content-id\": %s", json_quote_str (ctx, cid));
-- 
1.7.7.3

             reply	other threads:[~2012-01-11 10:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11 10:50 David Edmondson [this message]
2012-01-11 11:03 ` [PATCH] notmuch/emacs: Observe the charset of encoded parts, where known Tomi Ollila
2012-01-11 18:34 ` Dmitry Kurochkin
2012-01-12 12:00   ` David Edmondson
2012-01-12 14:17     ` Dmitry Kurochkin
2012-01-12 14:42       ` David Edmondson
2012-01-12 14:53         ` Dmitry Kurochkin
2012-01-12 13:31 ` [PATCH v2] notmuch/emacs: Observe the charset of text/html " David Edmondson
2012-01-12 18:49   ` Austin Clements
2012-01-12 19:14     ` David Edmondson
2012-01-13  9:44       ` [PATCH v3] " David Edmondson
2012-01-13 10:09         ` Tomi Ollila
2012-01-13 23:09         ` Austin Clements
2012-01-14  1:49         ` David Bremner

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=1326279001-28427-1-git-send-email-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).