Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / f7 / 1d9f017fb523fdbab33e754eda387affda6ec2
1 Return-Path: <dme@dme.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 93A59429E25\r
6         for <notmuch@notmuchmail.org>; Thu, 12 Jan 2012 05:31:24 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id s517Rn4Kr4W8 for <notmuch@notmuchmail.org>;\r
16         Thu, 12 Jan 2012 05:31:24 -0800 (PST)\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
18         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id D5B81431FB6\r
21         for <notmuch@notmuchmail.org>; Thu, 12 Jan 2012 05:31:23 -0800 (PST)\r
22 Received: by werm12 with SMTP id m12so1588653wer.26\r
23         for <notmuch@notmuchmail.org>; Thu, 12 Jan 2012 05:31:22 -0800 (PST)\r
24 Received: by 10.216.209.99 with SMTP id r77mr1515265weo.25.1326375082599;\r
25         Thu, 12 Jan 2012 05:31:22 -0800 (PST)\r
26 Received: from hotblack-desiato.hh.sledj.net\r
27         (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
28         by mx.google.com with ESMTPS id gf8sm5748909wbb.11.2012.01.12.05.31.20\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Thu, 12 Jan 2012 05:31:21 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id BBE76A029E; Thu, 12 Jan 2012 13:31:19 +0000 (GMT)\r
33 From: David Edmondson <dme@dme.org>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH v2] notmuch/emacs: Observe the charset of text/html parts,\r
36         where known.\r
37 Date: Thu, 12 Jan 2012 13:31:18 +0000\r
38 Message-Id: <1326375078-2279-1-git-send-email-dme@dme.org>\r
39 X-Mailer: git-send-email 1.7.7.3\r
40 In-Reply-To: <1326279001-28427-1-git-send-email-dme@dme.org>\r
41 References: <1326279001-28427-1-git-send-email-dme@dme.org>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Thu, 12 Jan 2012 13:31:24 -0000\r
55 \r
56 Add the charset of text/html parts to the JSON output of 'notmuch\r
57 -show' when it is known. Observe the encoding when rendering such\r
58 parts in emacs.\r
59 ---\r
60 \r
61 Add the charset only for text/html parts to avoid incorrectly\r
62 declaring the charset for JSON inline text/plain parts (as they have\r
63 already been converted to UTF-8).\r
64 \r
65  emacs/notmuch-show.el |    3 ++-\r
66  notmuch-show.c        |   19 ++++++++++++++-----\r
67  2 files changed, 16 insertions(+), 6 deletions(-)\r
68 \r
69 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
70 index 5502efd..0354a8e 100644\r
71 --- a/emacs/notmuch-show.el\r
72 +++ b/emacs/notmuch-show.el\r
73 @@ -328,7 +328,8 @@ message at DEPTH in the current thread."\r
74  current buffer, if possible."\r
75    (let ((display-buffer (current-buffer)))\r
76      (with-temp-buffer\r
77 -      (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
78 +      (let* ((charset (plist-get part :content-charset))\r
79 +            (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))\r
80         (if (and (mm-inlinable-p handle)\r
81                  (mm-inlined-p handle))\r
82             (let ((content (notmuch-show-get-bodypart-content msg part nth)))\r
83 diff --git a/notmuch-show.c b/notmuch-show.c\r
84 index 0200b9c..3d05da5 100644\r
85 --- a/notmuch-show.c\r
86 +++ b/notmuch-show.c\r
87 @@ -675,13 +675,22 @@ format_part_content_json (GMimeObject *part)\r
88             printf (", \"filename\": %s", json_quote_str (ctx, filename));\r
89      }\r
90  \r
91 -    if (g_mime_content_type_is_type (content_type, "text", "*") &&\r
92 -       !g_mime_content_type_is_type (content_type, "text", "html"))\r
93 +    if (g_mime_content_type_is_type (content_type, "text", "*"))\r
94      {\r
95 -       show_text_part_content (part, stream_memory);\r
96 -       part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (stream_memory));\r
97 +       if (g_mime_content_type_is_type (content_type, "text", "html"))\r
98 +       {\r
99 +           const char *content_charset = g_mime_object_get_content_type_parameter (GMIME_OBJECT (part), "charset");\r
100 +\r
101 +           if (content_charset != NULL)\r
102 +               printf (", \"content-charset\": %s", json_quote_str (ctx, content_charset));\r
103 +       }\r
104 +       else\r
105 +       {\r
106 +           show_text_part_content (part, stream_memory);\r
107 +           part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (stream_memory));\r
108  \r
109 -       printf (", \"content\": %s", json_quote_chararray (ctx, (char *) part_content->data, part_content->len));\r
110 +           printf (", \"content\": %s", json_quote_chararray (ctx, (char *) part_content->data, part_content->len));\r
111 +       }\r
112      }\r
113      else if (g_mime_content_type_is_type (content_type, "multipart", "*"))\r
114      {\r
115 -- \r
116 1.7.7.3\r
117 \r