unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch/emacs: Observe the charset of encoded parts, where known.
@ 2012-01-11 10:50 David Edmondson
  2012-01-11 11:03 ` Tomi Ollila
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: David Edmondson @ 2012-01-11 10:50 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-01-14  1:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-11 10:50 [PATCH] notmuch/emacs: Observe the charset of encoded parts, where known David Edmondson
2012-01-11 11:03 ` 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

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).