Re: [PATCH v3 06/16] Prefer gpg2 in the test suite if available
[notmuch-archives.git] / 34 / 21f0df5afa0a0932c833cdb51c1c613e8d75a5
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 BFB0C431FAF\r
6         for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 13:17:22 -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.138\r
10 X-Spam-Level: \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
13         autolearn=disabled\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 YyaQVkyMB5bE for <notmuch@notmuchmail.org>;\r
17         Sat, 24 Jan 2015 13:17:19 -0800 (PST)\r
18 Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
19         [18.9.25.15])\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 AF61B431FD5\r
23         for <notmuch@notmuchmail.org>; Sat, 24 Jan 2015 13:17:13 -0800 (PST)\r
24 X-AuditID: 1209190f-f79716d000000d1a-f8-54c40bd7d5d6\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-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
29         id 24.30.03354.7DB04C45; Sat, 24 Jan 2015 16:17:11 -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 t0OLH94W027945; \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 t0OLH6Bn007450\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-0005RU-KV; 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 2/8] emacs: Create an API for fetching parts as undecoded\r
45         binary\r
46 Date: Sat, 24 Jan 2015 16:16:57 -0500\r
47 Message-Id: <1422134223-20739-3-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+NgFrrJIsWRmVeSWpSXmKPExsUixCmqrXud+0iIweXrwhY3WrsZLfbd2cJk\r
53         sXouj8X1mzOZLd6snMfqwOqx6/lfJo+ds+6yexz+upDF49mqW8weWw69Zw5gjeKySUnNySxL\r
54         LdK3S+DK2HfmDnvBUe2KX1/fszQwPlPuYuTkkBAwkXgw6y0LhC0mceHeerYuRi4OIYHFTBJ7\r
55         N/9nh3A2Mkose72VBcK5yCTRcv8oM0iLkMAkRolDs9JAbDYBDYnftxYzgdgiAtISO+/OZgWx\r
56         mQXqJP7OOc8IYgsLBEss/H6ODcRmEVCVODl/BzuIzSvgIPH53xmgXg6gM+Qktq7zBglzCjhK\r
57         3NiwiwVilYNE9+dGtgmM/AsYGVYxyqbkVunmJmbmFKcm6xYnJ+blpRbpmujlZpbopaaUbmIE\r
58         h6Ak/w7GbweVDjEKcDAq8fD++HcoRIg1say4MvcQoyQHk5Io76pfh0OE+JLyUyozEosz4otK\r
59         c1KLDzFKcDArifBe2ACU401JrKxKLcqHSUlzsCiJ8276wRciJJCeWJKanZpakFoEk5Xh4FCS\r
60         4F3MdSRESLAoNT21Ii0zpwQhzcTBCTKcB2h4N0gNb3FBYm5xZjpE/hSjopQ4bzFIQgAkkVGa\r
61         B9cLSxGvGMWBXhHm3QdSxQNML3Ddr4AGMwENLth+AGRwSSJCSqqBsWdZZ5hrqr61ub+nRtOD\r
62         +jfNxrrTb9vckk58Pm95QVW3wBu1rjkdbeVesitOJm1+9+Vku/WR/DmMfqVr7/65Xb6Ibc8D\r
63         ldjbm/YwmSayLi5hE5rj5LM4/uuXDxM+eappr/HvmCjKncNYNCO48FR/NAtf3jblW2W8Z5s9\r
64         Pv5yTjJlvXnGY2GpEktxRqKhFnNRcSIAptdlW+wCAAA=\r
65 Cc: tomi.ollila@iki.fi\r
66 X-BeenThere: notmuch@notmuchmail.org\r
67 X-Mailman-Version: 2.1.13\r
68 Precedence: list\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:17:23 -0000\r
79 \r
80 The new function, `notmuch-get-bodypart-binary', replaces\r
81 `notmuch-get-bodypart-internal'.  Whereas the old function was really\r
82 meant for internal use in `notmuch-get-bodypart-content', it was used\r
83 in a few other places.  Since the difference between\r
84 `notmuch-get-bodypart-content' and `notmuch-get-bodypart-internal' was\r
85 unclear, these other uses were always confusing and potentially\r
86 inconsistent.  The new call clearly requests the part as undecoded\r
87 binary.\r
88 \r
89 This is step 1 of 2 in separating `notmuch-get-bodypart-content' into\r
90 two APIs for retrieving either undecoded binary or decoded text.\r
91 ---\r
92  emacs/notmuch-lib.el  | 28 ++++++++++++++--------------\r
93  emacs/notmuch-show.el | 22 +++++++++-------------\r
94  2 files changed, 23 insertions(+), 27 deletions(-)\r
95 \r
96 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
97 index fd25f7c..d4b6684 100644\r
98 --- a/emacs/notmuch-lib.el\r
99 +++ b/emacs/notmuch-lib.el\r
100 @@ -529,25 +529,25 @@ (defun notmuch-parts-filter-by-type (parts type)\r
101     (lambda (part) (notmuch-match-content-type (plist-get part :content-type) type))\r
102     parts))\r
103  \r
104 -;; Helper for parts which are generally not included in the default\r
105 -;; SEXP output.\r
106 -(defun notmuch-get-bodypart-internal (query part-number process-crypto)\r
107 -  (let ((args '("show" "--format=raw"))\r
108 -       (part-arg (format "--part=%s" part-number)))\r
109 -    (setq args (append args (list part-arg)))\r
110 -    (if process-crypto\r
111 -       (setq args (append args '("--decrypt"))))\r
112 -    (setq args (append args (list query)))\r
113 +(defun notmuch-get-bodypart-binary (msg part process-crypto)\r
114 +  "Return the unprocessed content of PART in MSG.\r
115 +\r
116 +This returns the \"raw\" content of the given part after content\r
117 +transfer decoding, but with no further processing (see the\r
118 +discussion of --format=raw in man notmuch-show).  In particular,\r
119 +this does no charset conversion."\r
120 +  (let ((args `("show" "--format=raw"\r
121 +               ,(format "--part=%d" (plist-get part :id))\r
122 +               ,@(when process-crypto '("--decrypt"))\r
123 +               ,(notmuch-id-to-query (plist-get msg :id)))))\r
124      (with-temp-buffer\r
125        (let ((coding-system-for-read 'no-conversion))\r
126 -       (progn\r
127 -         (apply 'call-process (append (list notmuch-command nil (list t nil) nil) args))\r
128 -         (buffer-string))))))\r
129 +       (apply #'call-process notmuch-command nil '(t nil) nil args)\r
130 +       (buffer-string)))))\r
131  \r
132  (defun notmuch-get-bodypart-content (msg part process-crypto)\r
133    (or (plist-get part :content)\r
134 -      (notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id))\r
135 -                                    (plist-get part :id) process-crypto)))\r
136 +      (notmuch-get-bodypart-binary msg part process-crypto)))\r
137  \r
138  ;; Workaround: The call to `mm-display-part' below triggers a bug in\r
139  ;; Emacs 24 if it attempts to use the shr renderer to display an HTML\r
140 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
141 index df2389e..b3e339e 100644\r
142 --- a/emacs/notmuch-show.el\r
143 +++ b/emacs/notmuch-show.el\r
144 @@ -579,16 +579,14 @@ (defun notmuch-show-w3m-cid-retrieve (url &rest args)\r
145         (let* ((msg (nth 1 matching-part))\r
146                (part (nth 2 matching-part))\r
147                (content (nth 3 matching-part))\r
148 -              (message-id (plist-get msg :id))\r
149 -              (part-number (plist-get part :id))\r
150                (content-type (plist-get part :content-type)))\r
151           ;; If we don't already have the content, get it and cache\r
152           ;; it, as some messages reference the same cid: part many\r
153           ;; times (hundreds!), which results in many calls to\r
154           ;; `notmuch part'.\r
155           (unless content\r
156 -           (setq content (notmuch-get-bodypart-internal (notmuch-id-to-query message-id)\r
157 -                                                             part-number notmuch-show-process-crypto))\r
158 +           (setq content (notmuch-get-bodypart-binary\r
159 +                          msg part notmuch-show-process-crypto))\r
160             (with-current-buffer w3m-current-buffer\r
161               (notmuch-show-w3m-cid-store-internal url msg part content)))\r
162           (insert content)\r
163 @@ -2162,15 +2160,14 @@ (defun notmuch-show-stash-git-send-email (&optional no-in-reply-to)\r
164  \r
165  ;; Interactive part functions and their helpers\r
166  \r
167 -(defun notmuch-show-generate-part-buffer (message-id nth)\r
168 +(defun notmuch-show-generate-part-buffer (msg part)\r
169    "Return a temporary buffer containing the specified part's content."\r
170    (let ((buf (generate-new-buffer " *notmuch-part*"))\r
171         (process-crypto notmuch-show-process-crypto))\r
172      (with-current-buffer buf\r
173 -      (setq notmuch-show-process-crypto process-crypto)\r
174 -      ;; Always acquires the part via `notmuch part', even if it is\r
175 -      ;; available in the SEXP output.\r
176 -      (insert (notmuch-get-bodypart-internal message-id nth notmuch-show-process-crypto)))\r
177 +      ;; This is always used in the content of mm handles, which\r
178 +      ;; expect undecoded, binary part content.\r
179 +      (insert (notmuch-get-bodypart-binary msg part process-crypto)))\r
180      buf))\r
181  \r
182  (defun notmuch-show-current-part-handle ()\r
183 @@ -2178,10 +2175,9 @@ (defun notmuch-show-current-part-handle ()\r
184  \r
185  This creates a temporary buffer for the part's content; the\r
186  caller is responsible for killing this buffer as appropriate."\r
187 -  (let* ((part (notmuch-show-get-part-properties))\r
188 -        (message-id (notmuch-show-get-message-id))\r
189 -        (nth (plist-get part :id))\r
190 -        (buf (notmuch-show-generate-part-buffer message-id nth))\r
191 +  (let* ((msg (notmuch-show-get-message-properties))\r
192 +        (part (notmuch-show-get-part-properties))\r
193 +        (buf (notmuch-show-generate-part-buffer msg part))\r
194          (computed-type (plist-get part :computed-type))\r
195          (filename (plist-get part :filename))\r
196          (disposition (if filename `(attachment (filename . ,filename)))))\r
197 -- \r
198 2.1.3\r
199 \r