[PATCH] notmuch/emacs: Observe the charset of encoded parts, where known.
David Edmondson
dme at dme.org
Wed Jan 11 02:50:01 PST 2012
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
More information about the notmuch
mailing list