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 21E62431FBD
\r
6 for <notmuch@notmuchmail.org>; Mon, 21 Apr 2014 11:38:13 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 jMEI27mNBzIb for <notmuch@notmuchmail.org>;
\r
16 Mon, 21 Apr 2014 11:38:09 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (dmz-mailsec-scanner-1.mit.edu
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id C4267431FC2
\r
22 for <notmuch@notmuchmail.org>; Mon, 21 Apr 2014 11:37:59 -0700 (PDT)
\r
23 X-AuditID: 1209190c-f794a6d000000c27-5f-535565873125
\r
24 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
25 (using TLS with cipher AES256-SHA (256/256 bits))
\r
26 (Client did not present a certificate)
\r
27 by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id 9F.C9.03111.78565535; Mon, 21 Apr 2014 14:37:59 -0400 (EDT)
\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
30 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s3LIbu8r018334;
\r
31 Mon, 21 Apr 2014 14:37:57 -0400
\r
32 Received: from drake.dyndns.org
\r
33 (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 s3LIbsGQ029718
\r
37 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
38 Mon, 21 Apr 2014 14:37:56 -0400
\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
40 (envelope-from <amdragon@mit.edu>)
\r
41 id 1WcJ6I-0003l6-EL; Mon, 21 Apr 2014 14:37:54 -0400
\r
42 From: Austin Clements <amdragon@MIT.EDU>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [PATCH 06/11] emacs: Remove broken `notmuch-get-bodypart-content' API
\r
45 Date: Mon, 21 Apr 2014 14:37:43 -0400
\r
46 Message-Id: <1398105468-14317-7-git-send-email-amdragon@mit.edu>
\r
47 X-Mailer: git-send-email 1.9.1
\r
48 In-Reply-To: <1398105468-14317-1-git-send-email-amdragon@mit.edu>
\r
49 References: <1398105468-14317-1-git-send-email-amdragon@mit.edu>
\r
50 X-Brightmail-Tracker:
\r
51 H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixCmqrdueGhps0HZC3uL6zZnMDowez1bd
\r
52 Yg5gjOKySUnNySxLLdK3S+DK+LLnGXtBp0ZFy7yjLA2MxxS6GDk5JARMJDYsmsEKYYtJXLi3
\r
53 ng3EFhKYzSSxpUGji5ELyN7IKLFm+xEmCOcOk8Tpb7OYIKrmMkp8Op8HYrMJaEhs27+cEcQW
\r
54 EZCW2Hl3NtBUDg5mATWJP10qIKawgJ/ElZslIBUsAqoST27OA9vLK+Ag0TzrChvEDXISJ49N
\r
55 BotzCjhKtK1+yQ6xyUFiw941TBMY+RcwMqxilE3JrdLNTczMKU5N1i1OTszLSy3SNdTLzSzR
\r
56 S00p3cQIDhhJnh2Mbw4qHWIU4GBU4uGVMAgNFmJNLCuuzD3EKMnBpCTK+yoKKMSXlJ9SmZFY
\r
57 nBFfVJqTWnyIUYKDWUmEd70mUI43JbGyKrUoHyYlzcGiJM771toqWEggPbEkNTs1tSC1CCYr
\r
58 w8GhJMFrlwLUKFiUmp5akZaZU4KQZuLgBBnOAzQ8CqSGt7ggMbc4Mx0if4pRUUqclzEZKCEA
\r
59 ksgozYPrhUX0K0ZxoFeEed1B2nmAyQCu+xXQYCagwU+2hIAMLklESEk1MBo8vL4le+Izns2P
\r
60 Z6/QkOuxl3++x2zpw/0somWsLsc9881EVUSCimZXJZ+XcpHnqL58Y+K9K187824vszdme3A7
\r
61 YHs+x9qA+cmSVwTrhNxETZuedzXXVXhWe1nrm85b39ffvf5qSb5skljx+RVOfLKz7PlPls86
\r
62 MOPzhr0NwkaPNN88y36ZrcRSnJFoqMVcVJwIAJy2+QrDAgAA
\r
63 X-BeenThere: notmuch@notmuchmail.org
\r
64 X-Mailman-Version: 2.1.13
\r
66 List-Id: "Use and development of the notmuch mail system."
\r
67 <notmuch.notmuchmail.org>
\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
71 List-Post: <mailto:notmuch@notmuchmail.org>
\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
75 X-List-Received-Date: Mon, 21 Apr 2014 18:38:13 -0000
\r
77 `notmuch-get-bodypart-content' could do two very different things,
\r
78 depending on conditions: for text/* parts other than text/html, it
\r
79 would return the part content as a multibyte Lisp string *after*
\r
80 charset conversion, while for other parts (including text/html), it
\r
81 would return binary part content without charset conversion.
\r
83 This commit completes the split of `notmuch-get-bodypart-content' into
\r
84 two different and explicit APIs: `notmuch-get-bodypart-binary' and
\r
85 `notmuch-get-bodypart-text'. It updates all callers to use one or the
\r
86 other depending on what's appropriate.
\r
88 emacs/notmuch-lib.el | 37 ++++++++++++++++++++++++++++---------
\r
89 emacs/notmuch-show.el | 8 ++++----
\r
90 2 files changed, 32 insertions(+), 13 deletions(-)
\r
92 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
93 index 4711098..ece29c3 100644
\r
94 --- a/emacs/notmuch-lib.el
\r
95 +++ b/emacs/notmuch-lib.el
\r
96 @@ -519,9 +519,25 @@ (defun notmuch-get-bodypart-binary (msg part process-crypto)
\r
97 (apply #'call-process notmuch-command nil '(t nil) nil args)
\r
100 -(defun notmuch-get-bodypart-content (msg part process-crypto)
\r
101 - (or (plist-get part :content)
\r
102 - (notmuch-get-bodypart-binary msg part process-crypto)))
\r
103 +(defun notmuch-get-bodypart-text (msg part process-crypto)
\r
104 + "Return the text content of PART in MSG.
\r
106 +This returns the content of the given part as a multibyte Lisp
\r
107 +string after performing content transfer decoding and any
\r
108 +necessary charset decoding. It is an error to use this for
\r
109 +non-text/* parts."
\r
110 + (let ((content (plist-get part :content)))
\r
111 + (when (not content)
\r
112 + ;; Use show --format=sexp to fetch decoded content
\r
113 + (let* ((args `("show" "--format=sexp" "--include-html"
\r
114 + ,(format "--part=%s" (plist-get part :id))
\r
115 + ,@(when process-crypto '("--decrypt"))
\r
116 + ,(notmuch-id-to-query (plist-get msg :id))))
\r
117 + (npart (apply #'notmuch-call-notmuch-sexp args)))
\r
118 + (setq content (plist-get npart :content))
\r
119 + (when (not content)
\r
120 + (error "Internal error: No :content from %S" args))))
\r
123 ;; Workaround: The call to `mm-display-part' below triggers a bug in
\r
124 ;; Emacs 24 if it attempts to use the shr renderer to display an HTML
\r
125 @@ -542,18 +558,21 @@ (defun notmuch-mm-display-part-inline (msg part content-type process-crypto)
\r
126 current buffer, if possible."
\r
127 (let ((display-buffer (current-buffer)))
\r
129 - ;; In case there is :content, the content string is already converted
\r
130 - ;; into emacs internal format. `gnus-decoded' is a fake charset,
\r
131 - ;; which means no further decoding (to be done by mm- functions).
\r
132 - (let* ((charset (if (plist-member part :content)
\r
134 + ;; In case we already have :content, use it and tell mm-* that
\r
135 + ;; it's already been charset-decoded by using the fake
\r
136 + ;; `gnus-decoded' charset. Otherwise, we'll fetch the binary
\r
137 + ;; part content and let mm-* decode it.
\r
138 + (let* ((have-content (plist-member part :content))
\r
139 + (charset (if have-content 'gnus-decoded
\r
140 (plist-get part :content-charset)))
\r
141 (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))
\r
142 ;; If the user wants the part inlined, insert the content and
\r
143 ;; test whether we are able to inline it (which includes both
\r
144 ;; capability and suitability tests).
\r
145 (when (mm-inlined-p handle)
\r
146 - (insert (notmuch-get-bodypart-content msg part process-crypto))
\r
148 + (insert (notmuch-get-bodypart-text msg part process-crypto))
\r
149 + (insert (notmuch-get-bodypart-binary msg part process-crypto)))
\r
150 (when (mm-inlinable-p handle)
\r
151 (set-buffer display-buffer)
\r
152 (mm-display-part handle)
\r
153 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
154 index e9867fd..537c558 100644
\r
155 --- a/emacs/notmuch-show.el
\r
156 +++ b/emacs/notmuch-show.el
\r
157 @@ -680,7 +680,7 @@ (defun notmuch-show-insert-part-text/plain (msg part content-type nth depth butt
\r
158 (let ((start (if button
\r
159 (button-start button)
\r
161 - (insert (notmuch-get-bodypart-content msg part notmuch-show-process-crypto))
\r
162 + (insert (notmuch-get-bodypart-text msg part notmuch-show-process-crypto))
\r
165 (narrow-to-region start (point-max))
\r
166 @@ -689,9 +689,9 @@ (defun notmuch-show-insert-part-text/plain (msg part content-type nth depth butt
\r
168 (defun notmuch-show-insert-part-text/calendar (msg part content-type nth depth button)
\r
169 (insert (with-temp-buffer
\r
170 - (insert (notmuch-get-bodypart-content msg part notmuch-show-process-crypto))
\r
171 - ;; notmuch-get-bodypart-content provides "raw", non-converted
\r
172 - ;; data. Replace CRLF with LF before icalendar can use it.
\r
173 + (insert (notmuch-get-bodypart-text msg part notmuch-show-process-crypto))
\r
174 + ;; notmuch-get-bodypart-text does no newline conversion.
\r
175 + ;; Replace CRLF with LF before icalendar can use it.
\r
176 (goto-char (point-min))
\r
177 (while (re-search-forward "\r\n" nil t)
\r
178 (replace-match "\n" nil nil))
\r