--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 20AC4431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 18 Jun 2012 23:56:25 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.075\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.075 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ HS_INDEX_PARAM=0.023, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id zSGNM+yZiXmJ for <notmuch@notmuchmail.org>;\r
+ Mon, 18 Jun 2012 23:56:23 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 271D7431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 18 Jun 2012 23:56:23 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1SgsML-0001RG-4h; Tue, 19 Jun 2012 07:56:17 +0100\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+ helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1SgsMK-0001mP-O1; Tue, 19 Jun 2012 07:56:16 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>,\r
+ Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: add function to toggle display of all\r
+ multipart/alternative parts\r
+In-Reply-To: <87zk80gvmb.fsf@servo.finestructure.net>\r
+References: <1339775751-18002-1-git-send-email-jani@nikula.org>\r
+ <87zk80gvmb.fsf@servo.finestructure.net>\r
+User-Agent: Notmuch/0.13.2+63~g548a9bf (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Tue, 19 Jun 2012 07:56:14 +0100\r
+Message-ID: <87pq8vokmp.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: 351edbcb77f9caf3de3706b36db7fbb1 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.5\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -1.5 points.\r
+ Summary of the scoring: \r
+ * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+ * medium trust\r
+ * [138.37.6.40 listed in list.dnswl.org]\r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+ * domain\r
+ * 0.5 QM_SPAMMYURI URI: \".info\" uri is common in spam.\r
+ * 0.0 HS_INDEX_PARAM URI: Link contains a common tracker pattern.\r
+ * 0.3 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 19 Jun 2012 06:56:25 -0000\r
+\r
+On Mon, 18 Jun 2012, Jameson Graef Rollins <jrollins@finestructure.net> wrote:\r
+> On Fri, Jun 15 2012, Jani Nikula <jani@nikula.org> wrote:\r
+>> Add function notmuch-show-toggle-multipart-alternative to make\r
+>> notmuch-show-all-multipart/alternative-parts buffer local, toggle its\r
+>> value in the buffer, and redisplay the thread with either all or\r
+>> preferred alternative parts expanded.\r
+>>\r
+>> A small wrinkle is that in order to make the variable survive\r
+>> notmuch-show-refresh-view (which is required for expanding/collapsing\r
+>> the parts, but ends up calling kill-all-local-variables through\r
+>> notmuch-show-mode) it is necessary to give it the permanent-local\r
+>> property.\r
+>\r
+> This is a very cool feature. I haven't looked closely at this but can't\r
+> this mechanism work the same as the other show-mode toggles, like crypto\r
+> or indenting? I wouldn't think it would require any more extra variable\r
+> stuff than what is used for those other toggles.\r
+>\r
+> Also, the *really* sweet thing would be if the toggle actually cycled\r
+> through display of the alternatives, only displaying one at a time.\r
+> That would be very swank.\r
+>\r
+> David Edmondson put together the other show-mode toggling stuff, so he\r
+> may be able to help with this as well.\r
+\r
+Hi\r
+\r
+I agree with this cycling approach but I think it needs to be per\r
+message rather than per buffer. I attach a rather hacky attempt at this\r
+below: on minimal testing it seems to work. But the lisp is really a bit\r
+gross. In particular I have no idea if I should be escaping the message\r
+ids (so this could break in unfortunate/insecure ways)\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+>From 4164456d225fca3c62bacfdc08a21cf4b32b5067 Mon Sep 17 00:00:00 2001\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+Date: Tue, 19 Jun 2012 07:50:17 +0100\r
+Subject: [PATCH] first attempt at cycling multipart\r
+\r
+---\r
+ emacs/notmuch-show.el | 29 ++++++++++++++++++++++++++---\r
+ 1 files changed, 26 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 0f54259..65a89fe 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -155,6 +155,10 @@ indentation."\r
+ (make-variable-buffer-local 'notmuch-show-indent-content)\r
+ (put 'notmuch-show-indent-content 'permanent-local t)\r
+ \r
++(defvar notmuch-show-message-multipart/alternative nil)\r
++(make-variable-buffer-local 'notmuch-show-message-multipart/alternative)\r
++(put 'notmuch-show-message-multipart/alternative 'permanent-local t)\r
++\r
+ (defcustom notmuch-show-stash-mlarchive-link-alist\r
+ '(("Gmane" . "http://mid.gmane.org/")\r
+ ("MARC" . "http://marc.info/?i=")\r
+@@ -537,9 +541,17 @@ message at DEPTH in the current thread."\r
+ \r
+ (defun notmuch-show-insert-part-multipart/alternative (msg part content-type nth depth declared-type)\r
+ (notmuch-show-insert-part-header nth declared-type content-type nil)\r
+- (let ((chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))\r
+- (inner-parts (plist-get part :content))\r
+- (start (point)))\r
++ (let* ((chosen-nth (or (lax-plist-get notmuch-show-message-multipart/alternative (plist-get msg :id)) 0))\r
++ (chosen-type (nth chosen-nth\r
++ (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))\r
++ (inner-parts (plist-get part :content))\r
++ (start (point)))\r
++ ;; If we have run out of possible content-types restart from the beginning\r
++ (unless chosen-type\r
++ (setq chosen-type (car (notmuch-multipart/alternative-choose (notmuch-show-multipart/*-to-list part))))\r
++ (setq notmuch-show-message-multipart/alternative\r
++ (lax-plist-put notmuch-show-message-multipart/alternative (plist-get msg :id) 0)))\r
++\r
+ ;; This inserts all parts of the chosen type rather than just one,\r
+ ;; but it's not clear that this is the wrong thing to do - which\r
+ ;; should be chosen if there are more than one that match?\r
+@@ -943,6 +955,16 @@ message at DEPTH in the current thread."\r
+ "Not processing cryptographic MIME parts."))\r
+ (notmuch-show-refresh-view))\r
+ \r
++(defun notmuch-show-cycle-message-multipart ()\r
++ "Cycle which part to display of a multipart messageToggle the display of non-matching messages."\r
++ (interactive)\r
++ (let* ((msg-id (notmuch-show-get-message-id t))\r
++ (next-part (1+ (or (lax-plist-get notmuch-show-message-multipart/alternative msg-id) 0))))\r
++ (setq notmuch-show-message-multipart/alternative\r
++ (lax-plist-put notmuch-show-message-multipart/alternative msg-id next-part))\r
++ (message "Cycling multipart/alternative for current message")\r
++ (notmuch-show-refresh-view)))\r
++\r
+ (defun notmuch-show-toggle-elide-non-matching ()\r
+ "Toggle the display of non-matching messages."\r
+ (interactive)\r
+@@ -1155,6 +1177,7 @@ reset based on the original query."\r
+ (define-key map "R" 'notmuch-show-reply)\r
+ (define-key map "|" 'notmuch-show-pipe-message)\r
+ (define-key map "w" 'notmuch-show-save-attachments)\r
++ (define-key map "W" 'notmuch-show-cycle-message-multipart)\r
+ (define-key map "V" 'notmuch-show-view-raw-message)\r
+ (define-key map "v" 'notmuch-show-view-all-mime-parts)\r
+ (define-key map "c" 'notmuch-show-stash-map)\r
+-- \r
+1.7.9.1\r
+\r
+\r
+\r