1 Return-Path: <m.walters@qmul.ac.uk>
\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 1EF5C431FAF
\r
6 for <notmuch@notmuchmail.org>; Fri, 10 Aug 2012 00:10:42 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.075 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 HS_INDEX_PARAM=0.023, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3]
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id DlOILAz4Qr0z for <notmuch@notmuchmail.org>;
\r
18 Fri, 10 Aug 2012 00:10:41 -0700 (PDT)
\r
19 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\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 C5637431FAE
\r
23 for <notmuch@notmuchmail.org>; Fri, 10 Aug 2012 00:10:40 -0700 (PDT)
\r
24 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
25 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
26 (envelope-from <m.walters@qmul.ac.uk>)
\r
27 id 1SzjMh-0004Uo-FL; Fri, 10 Aug 2012 08:10:35 +0100
\r
28 Received: from 94.196.1.178.threembb.co.uk ([94.196.1.178] helo=localhost)
\r
29 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
30 (envelope-from <m.walters@qmul.ac.uk>)
\r
31 id 1SzjMf-000026-CM; Fri, 10 Aug 2012 08:10:35 +0100
\r
32 From: Mark Walters <markwalters1009@gmail.com>
\r
33 To: Jameson Graef Rollins <jrollins@finestructure.net>,
\r
34 Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
\r
35 Subject: [PATCH v2] emacs: add function to toggle display of all
\r
36 multipart/alternative parts
\r
37 In-Reply-To: <87ipcrvlcw.fsf@servo.finestructure.net>
\r
38 References: <1339775751-18002-1-git-send-email-jani@nikula.org>
\r
39 <87zk80gvmb.fsf@servo.finestructure.net>
\r
40 <87pq8vokmp.fsf@qmul.ac.uk>
\r
41 <87ipcrvlcw.fsf@servo.finestructure.net>
\r
42 User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1
\r
43 (x86_64-pc-linux-gnu)
\r
44 Date: Fri, 10 Aug 2012 08:10:22 +0100
\r
45 Message-ID: <87r4rf9q8x.fsf@qmul.ac.uk>
\r
47 Content-Type: text/plain; charset=us-ascii
\r
48 X-Sender-Host-Address: 94.196.1.178
\r
49 X-QM-SPAM-Info: Sender has good ham record. :)
\r
50 X-QM-Body-MD5: 897d34d194abf11b27fa6d51cbf86e8a (of first 20000 bytes)
\r
51 X-SpamAssassin-Score: -1.8
\r
52 X-SpamAssassin-SpamBar: -
\r
53 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
55 spam. We require at least 5.0 points to mark a message as spam.
\r
56 This message scored -1.8 points.
\r
57 Summary of the scoring:
\r
58 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
60 * [138.37.6.40 listed in list.dnswl.org]
\r
61 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
62 provider * (markwalters1009[at]gmail.com)
\r
63 * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
\r
65 * 0.5 QM_SPAMMYURI URI: \".info\" uri is common in spam.
\r
66 * 0.0 HS_INDEX_PARAM URI: Link contains a common tracker pattern.
\r
67 X-QM-Scan-Virus: ClamAV says the message is clean
\r
68 X-BeenThere: notmuch@notmuchmail.org
\r
69 X-Mailman-Version: 2.1.13
\r
71 List-Id: "Use and development of the notmuch mail system."
\r
72 <notmuch.notmuchmail.org>
\r
73 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
75 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
76 List-Post: <mailto:notmuch@notmuchmail.org>
\r
77 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
78 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
79 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
80 X-List-Received-Date: Fri, 10 Aug 2012 07:10:42 -0000
\r
83 Some messages are sent as multipart/alternative but the alternatives
\r
84 contain different information. This allows the user to cycle which
\r
85 part to view. By default this is bound to 'W'.
\r
88 On Thu, 09 Aug 2012, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
\r
89 > On Mon, Jun 18 2012, Mark Walters <markwalters1009@gmail.com> wrote:
\r
90 >> I agree with this cycling approach but I think it needs to be per
\r
91 >> message rather than per buffer. I attach a rather hacky attempt at this
\r
92 >> below: on minimal testing it seems to work. But the lisp is really a bit
\r
93 >> gross. In particular I have no idea if I should be escaping the message
\r
94 >> ids (so this could break in unfortunate/insecure ways)
\r
96 > Thanks to broken Apple mail clients, I'm getting more and more messages
\r
97 > that have attachments hidden in multipart/"alternatives" to text/plain
\r
98 > parts. So I would really like to revive this patch.
\r
100 > I just tested it and it still applies to current master, and actually
\r
101 > seems to work great. 'W' cycles through which part is displayed in the
\r
102 > current message. Pretty much exactly what I want.
\r
104 > Mark seems to think this patch is less than ideal. One issue is that
\r
105 > it's trying to store a setting for a single displayed message in a
\r
106 > variable of full buffer scope. So he's storing a list of message ids
\r
109 >> +(defvar notmuch-show-message-multipart/alternative nil)
\r
110 >> +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative)
\r
111 >> +(put 'notmuch-show-message-multipart/alternative 'permanent-local t)
\r
113 >> + (lax-plist-put notmuch-show-message-multipart/alternative (plist-get msg :id) 0)))
\r
115 > I can see that might get a little hairy. Can any elisp experts out
\r
116 > there think of a better way to do this? (actually, this is making me
\r
117 > again want a show mode that only displays one message at a time (which I
\r
118 > guess means I need to try pick again)).
\r
120 This version at least uses the notmuch escaping for message-id which
\r
121 makes me a bit happier: it probably doesn't have any nasty security
\r
122 flaws. I do still feel that the lisp is a bit ugly though.
\r
124 Incidentally, Austin suggested I might be able to use text-properties
\r
125 rather than this big list. Unfortunately, I use
\r
126 notmuch-show-refresh-view to do the redisplay and that deletes all
\r
129 Note this is not very well tested as I have very few
\r
130 multipart/alternative messages.
\r
137 emacs/notmuch-show.el | 31 ++++++++++++++++++++++++++++---
\r
138 1 files changed, 28 insertions(+), 3 deletions(-)
\r
140 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
141 index dcfc190..dee6b85 100644
\r
142 --- a/emacs/notmuch-show.el
\r
143 +++ b/emacs/notmuch-show.el
\r
144 @@ -154,6 +154,10 @@ indentation."
\r
145 (make-variable-buffer-local 'notmuch-show-indent-content)
\r
146 (put 'notmuch-show-indent-content 'permanent-local t)
\r
148 +(defvar notmuch-show-message-multipart/alternative-display-part nil)
\r
149 +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative-display-part)
\r
150 +(put 'notmuch-show-message-multipart/alternative-display-part 'permanent-local t)
\r
152 (defcustom notmuch-show-stash-mlarchive-link-alist
\r
153 '(("Gmane" . "http://mid.gmane.org/")
\r
154 ("MARC" . "http://marc.info/?i=")
\r
155 @@ -536,9 +540,19 @@ message at DEPTH in the current thread."
\r
157 (defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth declared-type)
\r
158 (notmuch-show-insert-part-header nth declared-type content-type nil)
\r
159 - (let ((chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
\r
160 - (inner-parts (plist-get part :content))
\r
162 + (let* ((chosen-nth (or (lax-plist-get notmuch-show-message-multipart/alternative-display-part
\r
163 + (notmuch-id-to-query (plist-get msg :id))) 0))
\r
164 + (chosen-type (nth chosen-nth
\r
165 + (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
\r
166 + (inner-parts (plist-get part :content))
\r
168 + ;; If we have run out of possible content-types restart from the beginning
\r
169 + (unless chosen-type
\r
170 + (setq chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
\r
171 + (setq notmuch-show-message-multipart/alternative-display-part
\r
172 + (lax-plist-put notmuch-show-message-multipart/alternative-display-part
\r
173 + (notmuch-id-to-query (plist-get msg :id)) 0)))
\r
175 ;; This inserts all parts of the chosen type rather than just one,
\r
176 ;; but it's not clear that this is the wrong thing to do - which
\r
177 ;; should be chosen if there are more than one that match?
\r
178 @@ -942,6 +956,16 @@ message at DEPTH in the current thread."
\r
179 "Not processing cryptographic MIME parts."))
\r
180 (notmuch-show-refresh-view))
\r
182 +(defun notmuch-show-cycle-message-multipart ()
\r
183 + "Cycle which part to display of a multipart messageToggle the display of non-matching messages."
\r
185 + (let* ((msg-id (notmuch-show-get-message-id))
\r
186 + (next-part (1+ (or (lax-plist-get notmuch-show-message-multipart/alternative-display-part msg-id) 0))))
\r
187 + (setq notmuch-show-message-multipart/alternative-display-part
\r
188 + (lax-plist-put notmuch-show-message-multipart/alternative-display-part msg-id next-part))
\r
189 + (message "Cycling multipart/alternative for current message")
\r
190 + (notmuch-show-refresh-view)))
\r
192 (defun notmuch-show-toggle-elide-non-matching ()
\r
193 "Toggle the display of non-matching messages."
\r
195 @@ -1151,6 +1175,7 @@ reset based on the original query."
\r
196 (define-key map "R" 'notmuch-show-reply)
\r
197 (define-key map "|" 'notmuch-show-pipe-message)
\r
198 (define-key map "w" 'notmuch-show-save-attachments)
\r
199 + (define-key map "W" 'notmuch-show-cycle-message-multipart)
\r
200 (define-key map "V" 'notmuch-show-view-raw-message)
\r
201 (define-key map "v" 'notmuch-show-view-all-mime-parts)
\r
202 (define-key map "c" 'notmuch-show-stash-map)
\r