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 20AC4431FBC
\r
6 for <notmuch@notmuchmail.org>; Mon, 18 Jun 2012 23:56:25 -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 zSGNM+yZiXmJ for <notmuch@notmuchmail.org>;
\r
18 Mon, 18 Jun 2012 23:56:23 -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 271D7431FAF
\r
23 for <notmuch@notmuchmail.org>; Mon, 18 Jun 2012 23:56:23 -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 1SgsML-0001RG-4h; Tue, 19 Jun 2012 07:56:17 +0100
\r
28 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]
\r
30 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
31 (envelope-from <m.walters@qmul.ac.uk>)
\r
32 id 1SgsMK-0001mP-O1; Tue, 19 Jun 2012 07:56:16 +0100
\r
33 From: Mark Walters <markwalters1009@gmail.com>
\r
34 To: Jameson Graef Rollins <jrollins@finestructure.net>,
\r
35 Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
\r
36 Subject: Re: [PATCH] emacs: add function to toggle display of all
\r
37 multipart/alternative parts
\r
38 In-Reply-To: <87zk80gvmb.fsf@servo.finestructure.net>
\r
39 References: <1339775751-18002-1-git-send-email-jani@nikula.org>
\r
40 <87zk80gvmb.fsf@servo.finestructure.net>
\r
41 User-Agent: Notmuch/0.13.2+63~g548a9bf (http://notmuchmail.org) Emacs/23.4.1
\r
42 (x86_64-pc-linux-gnu)
\r
43 Date: Tue, 19 Jun 2012 07:56:14 +0100
\r
44 Message-ID: <87pq8vokmp.fsf@qmul.ac.uk>
\r
46 Content-Type: text/plain; charset=us-ascii
\r
47 X-Sender-Host-Address: 94.192.233.223
\r
48 X-QM-SPAM-Info: Sender has good ham record. :)
\r
49 X-QM-Body-MD5: 351edbcb77f9caf3de3706b36db7fbb1 (of first 20000 bytes)
\r
50 X-SpamAssassin-Score: -1.5
\r
51 X-SpamAssassin-SpamBar: -
\r
52 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
54 spam. We require at least 5.0 points to mark a message as spam.
\r
55 This message scored -1.5 points.
\r
56 Summary of the scoring:
\r
57 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
59 * [138.37.6.40 listed in list.dnswl.org]
\r
60 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
61 provider * (markwalters1009[at]gmail.com)
\r
62 * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
\r
64 * 0.5 QM_SPAMMYURI URI: \".info\" uri is common in spam.
\r
65 * 0.0 HS_INDEX_PARAM URI: Link contains a common tracker pattern.
\r
66 * 0.3 AWL AWL: From: address is in the auto white-list
\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: Tue, 19 Jun 2012 06:56:25 -0000
\r
82 On Mon, 18 Jun 2012, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
\r
83 > On Fri, Jun 15 2012, Jani Nikula <jani@nikula.org> wrote:
\r
84 >> Add function notmuch-show-toggle-multipart-alternative to make
\r
85 >> notmuch-show-all-multipart/alternative-parts buffer local, toggle its
\r
86 >> value in the buffer, and redisplay the thread with either all or
\r
87 >> preferred alternative parts expanded.
\r
89 >> A small wrinkle is that in order to make the variable survive
\r
90 >> notmuch-show-refresh-view (which is required for expanding/collapsing
\r
91 >> the parts, but ends up calling kill-all-local-variables through
\r
92 >> notmuch-show-mode) it is necessary to give it the permanent-local
\r
95 > This is a very cool feature. I haven't looked closely at this but can't
\r
96 > this mechanism work the same as the other show-mode toggles, like crypto
\r
97 > or indenting? I wouldn't think it would require any more extra variable
\r
98 > stuff than what is used for those other toggles.
\r
100 > Also, the *really* sweet thing would be if the toggle actually cycled
\r
101 > through display of the alternatives, only displaying one at a time.
\r
102 > That would be very swank.
\r
104 > David Edmondson put together the other show-mode toggling stuff, so he
\r
105 > may be able to help with this as well.
\r
109 I agree with this cycling approach but I think it needs to be per
\r
110 message rather than per buffer. I attach a rather hacky attempt at this
\r
111 below: on minimal testing it seems to work. But the lisp is really a bit
\r
112 gross. In particular I have no idea if I should be escaping the message
\r
113 ids (so this could break in unfortunate/insecure ways)
\r
119 >From 4164456d225fca3c62bacfdc08a21cf4b32b5067 Mon Sep 17 00:00:00 2001
\r
120 From: Mark Walters <markwalters1009@gmail.com>
\r
121 Date: Tue, 19 Jun 2012 07:50:17 +0100
\r
122 Subject: [PATCH] first attempt at cycling multipart
\r
125 emacs/notmuch-show.el | 29 ++++++++++++++++++++++++++---
\r
126 1 files changed, 26 insertions(+), 3 deletions(-)
\r
128 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
129 index 0f54259..65a89fe 100644
\r
130 --- a/emacs/notmuch-show.el
\r
131 +++ b/emacs/notmuch-show.el
\r
132 @@ -155,6 +155,10 @@ indentation."
\r
133 (make-variable-buffer-local 'notmuch-show-indent-content)
\r
134 (put 'notmuch-show-indent-content 'permanent-local t)
\r
136 +(defvar notmuch-show-message-multipart/alternative nil)
\r
137 +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative)
\r
138 +(put 'notmuch-show-message-multipart/alternative 'permanent-local t)
\r
140 (defcustom notmuch-show-stash-mlarchive-link-alist
\r
141 '(("Gmane" . "http://mid.gmane.org/")
\r
142 ("MARC" . "http://marc.info/?i=")
\r
143 @@ -537,9 +541,17 @@ message at DEPTH in the current thread."
\r
145 (defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth declared-type)
\r
146 (notmuch-show-insert-part-header nth declared-type content-type nil)
\r
147 - (let ((chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
\r
148 - (inner-parts (plist-get part :content))
\r
150 + (let* ((chosen-nth (or (lax-plist-get notmuch-show-message-multipart/alternative (plist-get msg :id)) 0))
\r
151 + (chosen-type (nth chosen-nth
\r
152 + (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
\r
153 + (inner-parts (plist-get part :content))
\r
155 + ;; If we have run out of possible content-types restart from the beginning
\r
156 + (unless chosen-type
\r
157 + (setq chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))
\r
158 + (setq notmuch-show-message-multipart/alternative
\r
159 + (lax-plist-put notmuch-show-message-multipart/alternative (plist-get msg :id) 0)))
\r
161 ;; This inserts all parts of the chosen type rather than just one,
\r
162 ;; but it's not clear that this is the wrong thing to do - which
\r
163 ;; should be chosen if there are more than one that match?
\r
164 @@ -943,6 +955,16 @@ message at DEPTH in the current thread."
\r
165 "Not processing cryptographic MIME parts."))
\r
166 (notmuch-show-refresh-view))
\r
168 +(defun notmuch-show-cycle-message-multipart ()
\r
169 + "Cycle which part to display of a multipart messageToggle the display of non-matching messages."
\r
171 + (let* ((msg-id (notmuch-show-get-message-id t))
\r
172 + (next-part (1+ (or (lax-plist-get notmuch-show-message-multipart/alternative msg-id) 0))))
\r
173 + (setq notmuch-show-message-multipart/alternative
\r
174 + (lax-plist-put notmuch-show-message-multipart/alternative msg-id next-part))
\r
175 + (message "Cycling multipart/alternative for current message")
\r
176 + (notmuch-show-refresh-view)))
\r
178 (defun notmuch-show-toggle-elide-non-matching ()
\r
179 "Toggle the display of non-matching messages."
\r
181 @@ -1155,6 +1177,7 @@ reset based on the original query."
\r
182 (define-key map "R" 'notmuch-show-reply)
\r
183 (define-key map "|" 'notmuch-show-pipe-message)
\r
184 (define-key map "w" 'notmuch-show-save-attachments)
\r
185 + (define-key map "W" 'notmuch-show-cycle-message-multipart)
\r
186 (define-key map "V" 'notmuch-show-view-raw-message)
\r
187 (define-key map "v" 'notmuch-show-view-all-mime-parts)
\r
188 (define-key map "c" 'notmuch-show-stash-map)
\r