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 B1885431FC2
\r
6 for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:43 -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 VrG3s8aRV+5u for <notmuch@notmuchmail.org>;
\r
16 Mon, 12 May 2014 05:29:38 -0700 (PDT)
\r
17 Received: from mail-we0-f169.google.com (mail-we0-f169.google.com
\r
18 [74.125.82.169]) (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 DF9BC431FC9
\r
21 for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:33 -0700 (PDT)
\r
22 Received: by mail-we0-f169.google.com with SMTP id u56so6864113wes.28
\r
23 for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:32 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
\r
28 bh=WPZlGZYbpH1b/MkEKfmRPD6mQPqcX7o640i99rZjADA=;
\r
29 b=OVJkKTbeiNAl+dvDCZek0M1Yl+DkdBMRHciU4XODUBhoxlduLfcexrGR5t2yNtDvbs
\r
30 u2XfUEeMCVvU8u3NcGAZ5o1YiLQ4Jzo95fItcpWdTAJ1/hbhNMj/Vscflk1o1LWc/F9r
\r
31 QHPAUAbLKtHWHnVQYFlutcGN8d3ytl7HTQ3Ixyt4D/6vHVeYFf1sTcrePbYZ3nTyV7Gm
\r
32 s4jdtQs/aNLoAX8FJRS8EMcIf3tfbJASeIu1kP2LinrHlH15zcgGoCGfkjp0/iDwthtM
\r
33 wWiNNKjx5ADpq0IvUubWbPAwFYbDDso5bKMO7na7PuUWdUQfOjH36V//nFKTPbS4QIBJ
\r
36 ALoCoQll/F3i7PX6qQYqv1tyZxjLOZdr7ZdxMS1DeHub0/m35AfGxzEeUoLUTG2YJlg2HQxBu1eJ
\r
37 X-Received: by 10.180.78.225 with SMTP id e1mr15384000wix.17.1399897772761;
\r
38 Mon, 12 May 2014 05:29:32 -0700 (PDT)
\r
39 Received: from hotblack-desiato.hh.sledj.net (disaster-area.hh.sledj.net.
\r
40 [81.149.164.25]) by mx.google.com with ESMTPSA id
\r
41 pj5sm15865576wic.20.2014.05.12.05.29.30 for <notmuch@notmuchmail.org>
\r
42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
43 Mon, 12 May 2014 05:29:30 -0700 (PDT)
\r
44 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
45 id 3C1EB10B326; Mon, 12 May 2014 13:29:29 +0100 (BST)
\r
46 From: David Edmondson <dme@dme.org>
\r
47 To: notmuch@notmuchmail.org
\r
48 Subject: [PATCH v3 3/9] emacs/show: Accommodate the lack of part header
\r
50 Date: Mon, 12 May 2014 13:29:23 +0100
\r
51 Message-Id: <1399897769-26809-4-git-send-email-dme@dme.org>
\r
52 X-Mailer: git-send-email 2.0.0.rc0
\r
53 In-Reply-To: <1399897769-26809-1-git-send-email-dme@dme.org>
\r
54 References: <87sixdujkv.fsf@qmul.ac.uk>
\r
55 <1399897769-26809-1-git-send-email-dme@dme.org>
\r
56 X-BeenThere: notmuch@notmuchmail.org
\r
57 X-Mailman-Version: 2.1.13
\r
59 List-Id: "Use and development of the notmuch mail system."
\r
60 <notmuch.notmuchmail.org>
\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
64 List-Post: <mailto:notmuch@notmuchmail.org>
\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
68 X-List-Received-Date: Mon, 12 May 2014 12:29:44 -0000
\r
70 Various pieces of code assumed (reasonably) that part header buttons
\r
71 are present. Modify them to avoid problems if no part headers were
\r
74 emacs/notmuch-show.el | 88 ++++++++++++++++++++++++++++-----------------------
\r
75 1 file changed, 48 insertions(+), 40 deletions(-)
\r
77 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
78 index f78a0ab..e511655 100644
\r
79 --- a/emacs/notmuch-show.el
\r
80 +++ b/emacs/notmuch-show.el
\r
81 @@ -494,36 +494,37 @@ message at DEPTH in the current thread."
\r
83 (defun notmuch-show-toggle-part-invisibility (&optional button)
\r
85 - (let* ((button (or button (button-at (point))))
\r
86 - (overlay (button-get button 'overlay))
\r
87 - (lazy-part (button-get button :notmuch-lazy-part)))
\r
88 - ;; We have a part to toggle if there is an overlay or if there is a lazy part.
\r
89 - ;; If neither is present we cannot toggle the part so we just return nil.
\r
90 - (when (or overlay lazy-part)
\r
91 - (let* ((show (button-get button :notmuch-part-hidden))
\r
92 - (new-start (button-start button))
\r
93 - (button-label (button-get button :base-label))
\r
94 - (old-point (point))
\r
95 - (properties (text-properties-at (button-start button)))
\r
96 - (inhibit-read-only t))
\r
97 - ;; Toggle the button itself.
\r
98 - (button-put button :notmuch-part-hidden (not show))
\r
99 - (goto-char new-start)
\r
100 - (insert "[ " button-label (if show " ]" " (hidden) ]"))
\r
101 - (set-text-properties new-start (point) properties)
\r
102 - (let ((old-end (button-end button)))
\r
103 - (move-overlay button new-start (point))
\r
104 - (delete-region (point) old-end))
\r
105 - (goto-char (min old-point (1- (button-end button))))
\r
106 - ;; Return nil if there is a lazy-part, it is empty, and we are
\r
107 - ;; trying to show it. In all other cases return t.
\r
110 - (button-put button :notmuch-lazy-part nil)
\r
111 - (notmuch-show-lazy-part lazy-part button))
\r
112 - ;; else there must be an overlay.
\r
113 - (overlay-put overlay 'invisible (not show))
\r
115 + (let ((button (or button (button-at (point)))))
\r
117 + (let ((overlay (button-get button 'overlay))
\r
118 + (lazy-part (button-get button :notmuch-lazy-part)))
\r
119 + ;; We have a part to toggle if there is an overlay or if there is a lazy part.
\r
120 + ;; If neither is present we cannot toggle the part so we just return nil.
\r
121 + (when (or overlay lazy-part)
\r
122 + (let* ((show (button-get button :notmuch-part-hidden))
\r
123 + (new-start (button-start button))
\r
124 + (button-label (button-get button :base-label))
\r
125 + (old-point (point))
\r
126 + (properties (text-properties-at (button-start button)))
\r
127 + (inhibit-read-only t))
\r
128 + ;; Toggle the button itself.
\r
129 + (button-put button :notmuch-part-hidden (not show))
\r
130 + (goto-char new-start)
\r
131 + (insert "[ " button-label (if show " ]" " (hidden) ]"))
\r
132 + (set-text-properties new-start (point) properties)
\r
133 + (let ((old-end (button-end button)))
\r
134 + (move-overlay button new-start (point))
\r
135 + (delete-region (point) old-end))
\r
136 + (goto-char (min old-point (1- (button-end button))))
\r
137 + ;; Return nil if there is a lazy-part, it is empty, and we are
\r
138 + ;; trying to show it. In all other cases return t.
\r
141 + (button-put button :notmuch-lazy-part nil)
\r
142 + (notmuch-show-lazy-part lazy-part button))
\r
143 + ;; else there must be an overlay.
\r
144 + (overlay-put overlay 'invisible (not show))
\r
147 ;; MIME part renderers
\r
149 @@ -632,14 +633,17 @@ message at DEPTH in the current thread."
\r
152 (defun notmuch-show-insert-part-multipart/signed (msg part content-type nth depth button)
\r
153 - (button-put button 'face 'notmuch-crypto-part-header)
\r
154 - ;; add signature status button if sigstatus provided
\r
156 + (button-put button 'face 'notmuch-crypto-part-header))
\r
157 + ;; Add signature status button if sigstatus provided.
\r
158 (if (plist-member part :sigstatus)
\r
159 (let* ((from (notmuch-show-get-header :From msg))
\r
160 (sigstatus (car (plist-get part :sigstatus))))
\r
161 (notmuch-crypto-insert-sigstatus-button sigstatus from))
\r
162 - ;; if we're not adding sigstatus, tell the user how they can get it
\r
163 - (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))
\r
164 + ;; If we're not adding the signature status, tell the user how
\r
165 + ;; they can get it.
\r
167 + (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts.")))
\r
169 (let ((inner-parts (plist-get part :content))
\r
171 @@ -653,17 +657,20 @@ message at DEPTH in the current thread."
\r
174 (defun notmuch-show-insert-part-multipart/encrypted (msg part content-type nth depth button)
\r
175 - (button-put button 'face 'notmuch-crypto-part-header)
\r
176 - ;; add encryption status button if encstatus specified
\r
178 + (button-put button 'face 'notmuch-crypto-part-header))
\r
179 + ;; Add encryption status button if encryption status is specified.
\r
180 (if (plist-member part :encstatus)
\r
181 (let ((encstatus (car (plist-get part :encstatus))))
\r
182 (notmuch-crypto-insert-encstatus-button encstatus)
\r
183 - ;; add signature status button if sigstatus specified
\r
184 + ;; Add signature status button if signature status is
\r
186 (if (plist-member part :sigstatus)
\r
187 (let* ((from (notmuch-show-get-header :From msg))
\r
188 (sigstatus (car (plist-get part :sigstatus))))
\r
189 (notmuch-crypto-insert-sigstatus-button sigstatus from))))
\r
190 - ;; if we're not adding encstatus, tell the user how they can get it
\r
191 + ;; If we're not adding the encryption status, tell the user how
\r
192 + ;; they can get it.
\r
193 (button-put button 'help-echo "Set notmuch-crypto-process-mime to process cryptographic MIME parts."))
\r
195 (let ((inner-parts (plist-get part :content))
\r
196 @@ -930,8 +937,9 @@ useful for quoting in replies)."
\r
199 (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)
\r
200 - (button-put button :notmuch-lazy-part
\r
201 - (list msg part mime-type nth depth button)))
\r
203 + (button-put button :notmuch-lazy-part
\r
204 + (list msg part mime-type nth depth button))))
\r
206 ;; Some of the body part handlers leave point somewhere up in the
\r
207 ;; part, so we make sure that we're down at the end.
\r