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 A8852431E62
\r
6 for <notmuch@notmuchmail.org>; Mon, 21 Apr 2014 11:38:14 -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 Ea7DYpC9RmEE for <notmuch@notmuchmail.org>;
\r
16 Mon, 21 Apr 2014 11:38:10 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.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 3671B431FC3
\r
22 for <notmuch@notmuchmail.org>; Mon, 21 Apr 2014 11:38:00 -0700 (PDT)
\r
23 X-AuditID: 1209190f-f790b6d000000c3a-cd-535565874487
\r
24 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\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-4.mit.edu (Symantec Messaging Gateway) with SMTP
\r
28 id 26.C8.03130.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-2.mit.edu (8.13.8/8.9.2) with ESMTP id s3LIbuwI009463;
\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 s3LIbsO6029722
\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-0003lC-GB; 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 08/11] emacs: Support caching in notmuch-get-bodypart-{binary,
\r
46 Date: Mon, 21 Apr 2014 14:37:45 -0400
\r
47 Message-Id: <1398105468-14317-9-git-send-email-amdragon@mit.edu>
\r
48 X-Mailer: git-send-email 1.9.1
\r
49 In-Reply-To: <1398105468-14317-1-git-send-email-amdragon@mit.edu>
\r
50 References: <1398105468-14317-1-git-send-email-amdragon@mit.edu>
\r
51 X-Brightmail-Tracker:
\r
52 H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixG6notueGhpscOCLkMX1mzOZHRg9nq26
\r
53 xRzAGMVlk5Kak1mWWqRvl8CVsXDXHeaCnXIVJ68dZmpg3CjRxcjJISFgIrFi7wMmCFtM4sK9
\r
54 9WwgtpDAbCaJhi9GXYxcQPZGRonm4+dYIZw7TBLTZ/xhgnDmMkrc23GbFaSFTUBDYtv+5Ywg
\r
55 toiAtMTOu7OB4hwczAJqEn+6VEDCwgLBEt9mtoKVsAioSmzfcZkFxOYVcJBYcHING8QVchIn
\r
56 j00GG8kp4CjRtvolO8RFDhIb9q5hmsDIv4CRYRWjbEpulW5uYmZOcWqybnFyYl5eapGuiV5u
\r
57 ZoleakrpJkZQ0HBK8u9g/HZQ6RCjAAejEg+vhEFosBBrYllxZe4hRkkOJiVR3ldRQCG+pPyU
\r
58 yozE4oz4otKc1OJDjBIczEoivOs1gXK8KYmVValF+TApaQ4WJXHet9ZWwUIC6YklqdmpqQWp
\r
59 RTBZGQ4OJQnehSlAjYJFqempFWmZOSUIaSYOTpDhPEDDL4LU8BYXJOYWZ6ZD5E8xKkqJ87aB
\r
60 JARAEhmleXC9sKh+xSgO9IowbwtIFQ8wIcB1vwIazAQ0+MmWEJDBJYkIKakGRjuLGcfurPb5
\r
61 ES0R/Gtihsj2K+qxHcu61ecenKV+qm27sMD3qgfTYzYya+vqlMi+u9+6espfgTougbfb9Neo
\r
62 Z/Ut3TNn9YPkRIMt9/+++zq/tlBE7boAu9PGYPZf3r/dEySPbFt/xie7N6PGcvV+c/ZFAmbm
\r
63 QhEMq+eZvfcq3Pqm789nlykWjkosxRmJhlrMRcWJAJUML5HFAgAA
\r
64 X-BeenThere: notmuch@notmuchmail.org
\r
65 X-Mailman-Version: 2.1.13
\r
67 List-Id: "Use and development of the notmuch mail system."
\r
68 <notmuch.notmuchmail.org>
\r
69 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
71 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
72 List-Post: <mailto:notmuch@notmuchmail.org>
\r
73 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
74 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
75 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
76 X-List-Received-Date: Mon, 21 Apr 2014 18:38:15 -0000
\r
78 (The actual code change here is small, but requires re-indenting
\r
81 emacs/notmuch-lib.el | 52 ++++++++++++++++++++++++++++++----------------------
\r
82 1 file changed, 30 insertions(+), 22 deletions(-)
\r
84 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
85 index fc67b14..fee8512 100644
\r
86 --- a/emacs/notmuch-lib.el
\r
87 +++ b/emacs/notmuch-lib.el
\r
88 @@ -503,33 +503,39 @@ (defun notmuch-parts-filter-by-type (parts type)
\r
89 (lambda (part) (notmuch-match-content-type (plist-get part :content-type) type))
\r
92 -(defun notmuch-get-bodypart-binary (msg part process-crypto)
\r
93 +(defun notmuch-get-bodypart-binary (msg part process-crypto &optional cache)
\r
94 "Return the unprocessed content of PART in MSG as a unibyte string.
\r
96 This returns the \"raw\" content of the given part after content
\r
97 transfer decoding, but with no further processing (see the
\r
98 discussion of --format=raw in man notmuch-show). In particular,
\r
99 this does no charset conversion."
\r
100 - (let ((args `("show" "--format=raw"
\r
101 - ,(format "--part=%d" (plist-get part :id))
\r
102 - ,@(when process-crypto '("--decrypt"))
\r
103 - ,(notmuch-id-to-query (plist-get msg :id)))))
\r
104 - (with-temp-buffer
\r
105 - ;; Emacs internally uses a UTF-8-like multibyte string
\r
106 - ;; representation by default (regardless of the coding system,
\r
107 - ;; which only affects how it goes from outside data to this
\r
108 - ;; internal representation). This *almost* never matters.
\r
109 - ;; Annoyingly, it does matter if we use this data in an image
\r
110 - ;; descriptor, since Emacs will use its internal data buffer
\r
111 - ;; directly and this multibyte representation corrupts binary
\r
112 - ;; image formats. Since the caller is asking for binary data, a
\r
113 - ;; unibyte string is a more appropriate representation anyway.
\r
114 - (set-buffer-multibyte nil)
\r
115 - (let ((coding-system-for-read 'no-conversion))
\r
116 - (apply #'call-process notmuch-command nil '(t nil) nil args)
\r
117 - (buffer-string)))))
\r
119 -(defun notmuch-get-bodypart-text (msg part process-crypto)
\r
120 + (let ((data (plist-get part :binary-content)))
\r
122 + (let ((args `("show" "--format=raw"
\r
123 + ,(format "--part=%d" (plist-get part :id))
\r
124 + ,@(when process-crypto '("--decrypt"))
\r
125 + ,(notmuch-id-to-query (plist-get msg :id)))))
\r
126 + (with-temp-buffer
\r
127 + ;; Emacs internally uses a UTF-8-like multibyte string
\r
128 + ;; representation by default (regardless of the coding
\r
129 + ;; system, which only affects how it goes from outside data
\r
130 + ;; to this internal representation). This *almost* never
\r
131 + ;; matters. Annoyingly, it does matter if we use this data
\r
132 + ;; in an image descriptor, since Emacs will use its internal
\r
133 + ;; data buffer directly and this multibyte representation
\r
134 + ;; corrupts binary image formats. Since the caller is
\r
135 + ;; asking for binary data, a unibyte string is a more
\r
136 + ;; appropriate representation anyway.
\r
137 + (set-buffer-multibyte nil)
\r
138 + (let ((coding-system-for-read 'no-conversion))
\r
139 + (apply #'call-process notmuch-command nil '(t nil) nil args)
\r
140 + (setq data (buffer-string)))))
\r
142 + (plist-put part :binary-content data)))
\r
145 +(defun notmuch-get-bodypart-text (msg part process-crypto &optional cache)
\r
146 "Return the text content of PART in MSG.
\r
148 This returns the content of the given part as a multibyte Lisp
\r
149 @@ -546,7 +552,9 @@ (defun notmuch-get-bodypart-text (msg part process-crypto)
\r
150 (npart (apply #'notmuch-call-notmuch-sexp args)))
\r
151 (setq content (plist-get npart :content))
\r
152 (when (not content)
\r
153 - (error "Internal error: No :content from %S" args))))
\r
154 + (error "Internal error: No :content from %S" args)))
\r
156 + (plist-put part :content content)))
\r
159 ;; Workaround: The call to `mm-display-part' below triggers a bug in
\r