1 Return-Path: <amdragon@mit.edu>
\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 914B5431FD5
\r
6 for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 13:18:02 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.138 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_MED=-2.3]
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 9K2thYHTkCG8 for <notmuch@notmuchmail.org>;
\r
17 Sat, 24 Jan 2015 13:17:59 -0800 (PST)
\r
18 Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu
\r
20 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id 59341429E29
\r
23 for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 13:17:21 -0800 (PST)
\r
24 X-AuditID: 12074423-f797b6d000000cfe-e0-54c40be07960
\r
25 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
26 (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
27 (Client did not present a certificate)
\r
28 by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP
\r
29 id DE.64.03326.0EB04C45; Sat, 24 Jan 2015 16:17:20 -0500 (EST)
\r
30 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
31 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id t0OLH9Mh027943;
\r
32 Sat, 24 Jan 2015 16:17:09 -0500
\r
33 Received: from drake (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
34 [216.15.114.40]) (authenticated bits=0)
\r
35 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
36 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id t0OLH6UH007454
\r
37 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);
\r
38 Sat, 24 Jan 2015 16:17:07 -0500
\r
39 Received: from amthrax by drake with local (Exim 4.84)
\r
40 (envelope-from <amdragon@mit.edu>)
\r
41 id 1YF84n-0005RX-Ky; Sat, 24 Jan 2015 16:17:05 -0500
\r
42 From: Austin Clements <amdragon@mit.edu>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH v2 3/8] emacs: Remove broken `notmuch-get-bodypart-content'
\r
46 Date: Sat, 24 Jan 2015 16:16:58 -0500
\r
47 Message-Id: <1422134223-20739-4-git-send-email-amdragon@mit.edu>
\r
48 X-Mailer: git-send-email 2.1.3
\r
49 In-Reply-To: <1422134223-20739-1-git-send-email-amdragon@mit.edu>
\r
50 References: <1422134223-20739-1-git-send-email-amdragon@mit.edu>
\r
51 X-Brightmail-Tracker:
\r
52 H4sIAAAAAAAAA+NgFrrJIsWRmVeSWpSXmKPExsUixCmqrfuA+0iIwfHJihY3WrsZLfbd2cJk
\r
53 sXouj8X1mzOZLd6snMfqwOqx6/lfJo+ds+6yexz+upDF49mqW8weWw69Zw5gjeKySUnNySxL
\r
54 LdK3S+DKmHGqm6mgU6Pix/QTrA2MxxS6GDk5JARMJJacvMwEYYtJXLi3ng3EFhJYzCRx8bZ9
\r
55 FyMXkL2RUeLpuk+MEM5FJokbZy6zQDiTGCVezpwP1s4moCHx+9ZiMFtEQFpi593ZrCA2s0Cd
\r
56 xN855xlBbGEBf4kLV7rZQWwWAVWJNzeXgtm8Ag4SS1c3Aa3mADpDTmLrOm+QMKeAo8SNDbtY
\r
57 IC5ykOj+3Mg2gZF/ASPDKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl0zvdzMEr3UlNJNjKAQZHdR
\r
58 3sH456DSIUYBDkYlHt4f/w6FCLEmlhVX5h5ilORgUhLlXfXrcIgQX1J+SmVGYnFGfFFpTmrx
\r
59 IUYJDmYlEd4LG4ByvCmJlVWpRfkwKWkOFiVx3k0/+EKEBNITS1KzU1MLUotgsjIcHEoSvIzA
\r
60 WBMSLEpNT61Iy8wpQUgzcXCCDOcBGs4KUsNbXJCYW5yZDpE/xagoJc77lQsoIQCSyCjNg+uF
\r
61 pYhXjOJArwjz1oNU8QDTC1z3K6DBTECDC7YfABlckoiQkmpgXD/n+A5J/32GvtMMrPibUiND
\r
62 T2tXmFpMzV7Rp2jF4L+4Xul77sKrGR8Ddi5ez7FmUdJHNZXssu3OT+pl31yfVyCzbMNmNX+l
\r
63 S1JrrlcGr591VLKye9d18950XZF3eobPOX+FaZiFnlCdE7D3WcXcrvIDO9Y+vauc5PFp+R61
\r
64 gNklD36s8fZpVmIpzkg01GIuKk4EAPTnEprsAgAA
\r
65 Cc: tomi.ollila@iki.fi
\r
66 X-BeenThere: notmuch@notmuchmail.org
\r
67 X-Mailman-Version: 2.1.13
\r
69 List-Id: "Use and development of the notmuch mail system."
\r
70 <notmuch.notmuchmail.org>
\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
74 List-Post: <mailto:notmuch@notmuchmail.org>
\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
77 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
78 X-List-Received-Date: Sat, 24 Jan 2015 21:18:03 -0000
\r
80 `notmuch-get-bodypart-content' could do two very different things,
\r
81 depending on conditions: for text/* parts other than text/html, it
\r
82 would return the part content as a multibyte Lisp string *after*
\r
83 charset conversion, while for other parts (including text/html), it
\r
84 would return binary part content without charset conversion.
\r
86 This commit completes the split of `notmuch-get-bodypart-content' into
\r
87 two different and explicit APIs: `notmuch-get-bodypart-binary' and
\r
88 `notmuch-get-bodypart-text'. It updates all callers to use one or the
\r
89 other depending on what's appropriate.
\r
91 emacs/notmuch-lib.el | 37 ++++++++++++++++++++++++++++---------
\r
92 emacs/notmuch-show.el | 8 ++++----
\r
93 2 files changed, 32 insertions(+), 13 deletions(-)
\r
95 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
96 index d4b6684..a0a95d8 100644
\r
97 --- a/emacs/notmuch-lib.el
\r
98 +++ b/emacs/notmuch-lib.el
\r
99 @@ -545,9 +545,25 @@ (defun notmuch-get-bodypart-binary (msg part process-crypto)
\r
100 (apply #'call-process notmuch-command nil '(t nil) nil args)
\r
101 (buffer-string)))))
\r
103 -(defun notmuch-get-bodypart-content (msg part process-crypto)
\r
104 - (or (plist-get part :content)
\r
105 - (notmuch-get-bodypart-binary msg part process-crypto)))
\r
106 +(defun notmuch-get-bodypart-text (msg part process-crypto)
\r
107 + "Return the text content of PART in MSG.
\r
109 +This returns the content of the given part as a multibyte Lisp
\r
110 +string after performing content transfer decoding and any
\r
111 +necessary charset decoding. It is an error to use this for
\r
112 +non-text/* parts."
\r
113 + (let ((content (plist-get part :content)))
\r
114 + (when (not content)
\r
115 + ;; Use show --format=sexp to fetch decoded content
\r
116 + (let* ((args `("show" "--format=sexp" "--include-html"
\r
117 + ,(format "--part=%s" (plist-get part :id))
\r
118 + ,@(when process-crypto '("--decrypt"))
\r
119 + ,(notmuch-id-to-query (plist-get msg :id))))
\r
120 + (npart (apply #'notmuch-call-notmuch-sexp args)))
\r
121 + (setq content (plist-get npart :content))
\r
122 + (when (not content)
\r
123 + (error "Internal error: No :content from %S" args))))
\r
126 ;; Workaround: The call to `mm-display-part' below triggers a bug in
\r
127 ;; Emacs 24 if it attempts to use the shr renderer to display an HTML
\r
128 @@ -568,18 +584,21 @@ (defun notmuch-mm-display-part-inline (msg part content-type process-crypto)
\r
129 current buffer, if possible."
\r
130 (let ((display-buffer (current-buffer)))
\r
132 - ;; In case there is :content, the content string is already converted
\r
133 - ;; into emacs internal format. `gnus-decoded' is a fake charset,
\r
134 - ;; which means no further decoding (to be done by mm- functions).
\r
135 - (let* ((charset (if (plist-member part :content)
\r
137 + ;; In case we already have :content, use it and tell mm-* that
\r
138 + ;; it's already been charset-decoded by using the fake
\r
139 + ;; `gnus-decoded' charset. Otherwise, we'll fetch the binary
\r
140 + ;; part content and let mm-* decode it.
\r
141 + (let* ((have-content (plist-member part :content))
\r
142 + (charset (if have-content 'gnus-decoded
\r
143 (plist-get part :content-charset)))
\r
144 (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))
\r
145 ;; If the user wants the part inlined, insert the content and
\r
146 ;; test whether we are able to inline it (which includes both
\r
147 ;; capability and suitability tests).
\r
148 (when (mm-inlined-p handle)
\r
149 - (insert (notmuch-get-bodypart-content msg part process-crypto))
\r
151 + (insert (notmuch-get-bodypart-text msg part process-crypto))
\r
152 + (insert (notmuch-get-bodypart-binary msg part process-crypto)))
\r
153 (when (mm-inlinable-p handle)
\r
154 (set-buffer display-buffer)
\r
155 (mm-display-part handle)
\r
156 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
157 index b3e339e..f29428a 100644
\r
158 --- a/emacs/notmuch-show.el
\r
159 +++ b/emacs/notmuch-show.el
\r
160 @@ -702,7 +702,7 @@ (defun notmuch-show-insert-part-text/plain (msg part content-type nth depth butt
\r
161 (let ((start (if button
\r
162 (button-start button)
\r
164 - (insert (notmuch-get-bodypart-content msg part notmuch-show-process-crypto))
\r
165 + (insert (notmuch-get-bodypart-text msg part notmuch-show-process-crypto))
\r
168 (narrow-to-region start (point-max))
\r
169 @@ -711,9 +711,9 @@ (defun notmuch-show-insert-part-text/plain (msg part content-type nth depth butt
\r
171 (defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth button)
\r
172 (insert (with-temp-buffer
\r
173 - (insert (notmuch-get-bodypart-content msg part notmuch-show-process-crypto))
\r
174 - ;; notmuch-get-bodypart-content provides "raw", non-converted
\r
175 - ;; data. Replace CRLF with LF before icalendar can use it.
\r
176 + (insert (notmuch-get-bodypart-text msg part notmuch-show-process-crypto))
\r
177 + ;; notmuch-get-bodypart-text does no newline conversion.
\r
178 + ;; Replace CRLF with LF before icalendar can use it.
\r
179 (goto-char (point-min))
\r
180 (while (re-search-forward "\r\n" nil t)
\r
181 (replace-match "\n" nil nil))
\r