--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 AEA41431FBC\r
+ for <notmuch@notmuchmail.org>; Sun, 2 Dec 2012 16:59:04 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.224\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.224 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ HS_INDEX_PARAM=0.023, RCVD_IN_DNSWL_LOW=-0.7] 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 PEcaEqbEhoq8 for <notmuch@notmuchmail.org>;\r
+ Sun, 2 Dec 2012 16:59:00 -0800 (PST)\r
+Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com\r
+ [74.125.82.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 8C1A1431FC0 for <notmuch@notmuchmail.org>; Sun, 2 Dec 2012 16:58:52 -0800\r
+ (PST)\r
+Received: by mail-wg0-f47.google.com with SMTP id dq11so1088819wgb.2\r
+ for <notmuch@notmuchmail.org>; Sun, 02 Dec 2012 16:58:51 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+ bh=5wd9b27rjZYb3raJe7qIguUAH0rI2LNuqZOy14ACoVs=;\r
+ b=v4bVfzUySonKeR4Jha9t5iFtfA/7TQ8oYUvnwuVG+Aqgg/EcGSS6dGoO4u/JrQT/CG\r
+ 37ux78gYnXoCq8pKIkVt1iRGCd5SqMU+V1Utl43n3MivSNvW+Gnh4JEA1ZC9Kmb9dAet\r
+ Pa5iuKhTzGk/gVKjWIiZN04gq574X+LY03qGqJX/aCGTe9b6apCUXxzBa723iI0FJRPS\r
+ DPU/ovWGE1nePYkQLKGXvTTkZ/0BrOa5mTTcToWIucdfzAcA+/vLWTvsVAeX/N956mj0\r
+ v1lN4FkZNAxaT3Y7N5/lMKPjwEAgZNYSW4Fx0vrrfs6XuBT+kF25VelzaArhvHCCx5ao\r
+ qT2A==\r
+Received: by 10.180.73.80 with SMTP id j16mr6912588wiv.5.1354496331325;\r
+ Sun, 02 Dec 2012 16:58:51 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPS id en20sm10287474wid.4.2012.12.02.16.58.49\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sun, 02 Dec 2012 16:58:50 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 2/3] emacs: allow the user to toggle the visibility of\r
+ multipart/alternative parts\r
+Date: Mon, 3 Dec 2012 00:58:36 +0000\r
+Message-Id: <1354496317-24564-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1354496317-24564-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1354496317-24564-1-git-send-email-markwalters1009@gmail.com>\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: Mon, 03 Dec 2012 00:59:04 -0000\r
+\r
+This patch adds a keybinding to the buttons in the notmuch-show emacs\r
+buffer to allow the user to toggle the visibility of each part of a\r
+message in the show buffer. This is particularly useful for\r
+multipart/alternative parts where the parts are not really\r
+alternatives but contain different information.\r
+---\r
+ emacs/notmuch-show.el | 48 +++++++++++++++++++++++++++++++++++++++---------\r
+ 1 files changed, 39 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index cc0487c..9a33d28 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -154,6 +154,11 @@ 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-display-parts nil\r
++ "A list of message-ids/parts where the user has overridden notmuch display choice")\r
++(make-variable-buffer-local 'notmuch-show-message-multipart/alternative-display-parts)\r
++(put 'notmuch-show-message-multipart/alternative-display-parts '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
+@@ -469,6 +474,7 @@ message at DEPTH in the current thread."\r
+ (define-key map "v" 'notmuch-show-part-button-view)\r
+ (define-key map "o" 'notmuch-show-part-button-interactively-view)\r
+ (define-key map "|" 'notmuch-show-part-button-pipe)\r
++ (define-key map "t" 'notmuch-show-part-button-internally-show)\r
+ map)\r
+ "Submap for button commands")\r
+ (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
+@@ -545,6 +551,16 @@ message at DEPTH in the current thread."\r
+ (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
+ (mm-pipe-part handle))))\r
+ \r
++(defun notmuch-show-internally-show-part (message-id nth &optional filename content-type)\r
++ "Set a part to be displayed internally"\r
++ (let ((current-parts (lax-plist-get notmuch-show-message-multipart/alternative-display-parts message-id)))\r
++ (setq notmuch-show-message-multipart/alternative-display-parts\r
++ (lax-plist-put notmuch-show-message-multipart/alternative-display-parts message-id\r
++ (if (memq nth current-parts)\r
++ (delq nth current-parts)\r
++ (cons nth current-parts)))))\r
++ (notmuch-show-refresh-view))\r
++\r
+ (defun notmuch-show-multipart/*-to-list (part)\r
+ (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
+ (plist-get part :content)))\r
+@@ -557,12 +573,12 @@ message at DEPTH in the current thread."\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
++\r
+ (mapc (lambda (inner-part)\r
+ (let ((inner-type (plist-get inner-part :content-type)))\r
+- (if (or notmuch-show-all-multipart/alternative-parts\r
+- (string= chosen-type inner-type))\r
+- (notmuch-show-insert-bodypart msg inner-part depth)\r
+- (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))\r
++ (notmuch-show-insert-bodypart msg inner-part depth\r
++ (not (or notmuch-show-all-multipart/alternative-parts\r
++ (string= chosen-type inner-type))))))\r
+ inner-parts)\r
+ \r
+ (when notmuch-show-indent-multipart\r
+@@ -830,11 +846,20 @@ message at DEPTH in the current thread."\r
+ (setq handlers (cdr handlers))))\r
+ t)\r
+ \r
+-(defun notmuch-show-insert-bodypart (msg part depth)\r
+- "Insert the body part PART at depth DEPTH in the current thread."\r
+- (let ((content-type (downcase (plist-get part :content-type)))\r
++(defun notmuch-show-insert-bodypart (msg part depth &optional not-shown)\r
++ "Insert the body part PART at depth DEPTH in the current thread.\r
++\r
++If not-shown is TRUE then do not show the part unless the user\r
++has overridden the default for this part"\r
++ (let ((user-parts (lax-plist-get notmuch-show-message-multipart/alternative-display-parts\r
++ (notmuch-id-to-query (plist-get msg :id))))\r
++ (content-type (downcase (plist-get part :content-type)))\r
+ (nth (plist-get part :id)))\r
+- (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\r
++ (when (memq nth user-parts)\r
++ (setq not-shown (not not-shown)))\r
++ (if not-shown\r
++ (notmuch-show-insert-part-header nth content-type content-type nil " (not shown)")\r
++ (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)))\r
+ ;; Some of the body part handlers leave point somewhere up in the\r
+ ;; part, so we make sure that we're down at the end.\r
+ (goto-char (point-max))\r
+@@ -1185,7 +1210,8 @@ non-nil) then the state of the buffer (open/closed messages) is\r
+ reset based on the original query."\r
+ (interactive "P")\r
+ (let ((inhibit-read-only t)\r
+- (state (unless reset-state\r
++ (state (if reset-state\r
++ (setq notmuch-show-message-multipart/alternative-display-parts nil)\r
+ (notmuch-show-capture-state))))\r
+ (erase-buffer)\r
+ (notmuch-show-build-buffer)\r
+@@ -1980,6 +2006,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
+ (interactive)\r
+ (notmuch-show-part-button-internal button #'notmuch-show-pipe-part))\r
+ \r
++(defun notmuch-show-part-button-internally-show (&optional button)\r
++ (interactive)\r
++ (notmuch-show-part-button-internal button #'notmuch-show-internally-show-part))\r
++\r
+ (defun notmuch-show-part-button-internal (button handler)\r
+ (let ((button (or button (button-at (point)))))\r
+ (if button\r
+-- \r
+1.7.9.1\r
+\r