Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 38141431FD0 for ; Wed, 11 Jan 2012 02:50:10 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 835WsCZRyG2V for ; Wed, 11 Jan 2012 02:50:08 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 59294431FB6 for ; Wed, 11 Jan 2012 02:50:08 -0800 (PST) Received: by wibhr12 with SMTP id hr12so290306wib.26 for ; Wed, 11 Jan 2012 02:50:07 -0800 (PST) Received: by 10.180.82.41 with SMTP id f9mr18595934wiy.7.1326279007335; Wed, 11 Jan 2012 02:50:07 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id o17sm1165524wbh.19.2012.01.11.02.50.05 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Jan 2012 02:50:06 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 444E29FCB6; Wed, 11 Jan 2012 10:50:04 +0000 (GMT) From: David Edmondson 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 Message-Id: <1326279001-28427-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.7.3 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 10:50:10 -0000 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