--- /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 1DDED431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 9 Jun 2013 21:57:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 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
+ 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 ex8p8YgYjjPS for <notmuch@notmuchmail.org>;\r
+ Sun, 9 Jun 2013 21:57:33 -0700 (PDT)\r
+Received: from mail-ea0-f179.google.com (mail-ea0-f179.google.com\r
+ [209.85.215.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id AD80C431FBD\r
+ for <notmuch@notmuchmail.org>; Sun, 9 Jun 2013 21:57:26 -0700 (PDT)\r
+Received: by mail-ea0-f179.google.com with SMTP id b15so3882109eae.24\r
+ for <notmuch@notmuchmail.org>; Sun, 09 Jun 2013 21:57:25 -0700 (PDT)\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=/rjrXVYrKPJtKMwtmKMl31jf2/xCmRSmYTgBB3dJN8s=;\r
+ b=GYX7Zt6nRbfrfzc1848gx92gr8ng6b0eP/v4R7t1ymzln5G3fZkCIFrnLKAIWMABto\r
+ uCC1yKC5IjDYWo7LKlLwt4dksiIcRjrdQFVgyowjN5EURuygchjJRhxN4lE6pIeP70Iu\r
+ zZQd64pajfuXJULaDi+IzDTClrJMXOwFSwy2WGIEJxcn1Jfk4kX5wkd0u0UdtNUbQZCL\r
+ 55l9ig6IS1p0PhZqDfN+BymcjeXgkmaT9kj24twKK64/ZbYmHb4RGKA4YKDtK81VT7/k\r
+ JXR9nefs2AymXuB7E9n5traXxynjU9xgwb5J1SDvjdXX+W9Y++bAD+Q3i4ML2UiIe/Z1\r
+ qIPw==\r
+X-Received: by 10.14.98.194 with SMTP id v42mr9072097eef.61.1370840245520;\r
+ Sun, 09 Jun 2013 21:57:25 -0700 (PDT)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id y2sm20318516eeu.2.2013.06.09.21.57.24\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 09 Jun 2013 21:57:25 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+ Austin Clements <aclements@csail.mit.edu>\r
+Subject: [PATCH v5 4/6] emacs: show: modify the way hidden state is recorded.\r
+Date: Mon, 10 Jun 2013 05:57:11 +0100\r
+Message-Id: <1370840233-23258-5-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1370840233-23258-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1370840233-23258-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, 10 Jun 2013 04:57:39 -0000\r
+\r
+Previously, whether a part was hidden or shown was recorded in the\r
+invisibility/visibility of the part overlay. Since we are going to\r
+have lazily rendered parts with no overlay store the hidden/shown\r
+state in the part button itself.\r
+\r
+Additionally, in preparation for the invisible part handling move the\r
+actual hiding of the hidden parts to insert-bodypart from\r
+create-part-overlays.\r
+\r
+Finally, we will need to know whether a part-insertion has done\r
+anything (it won't if the invisible part cannot be displayed by emacs)\r
+so we slightly rejig the code order in\r
+notmuch-show-toggle-part-invisibility to make it easier for the\r
+function to set an appropriate return value.\r
+---\r
+ emacs/notmuch-show.el | 25 ++++++++++++++-----------\r
+ 1 files changed, 14 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 0a0451b..43aa88b 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -482,7 +482,8 @@ message at DEPTH in the current thread."\r
+ (insert-button\r
+ (concat "[ " base-label " ]")\r
+ :base-label base-label\r
+- :type 'notmuch-show-part-button-type))\r
++ :type 'notmuch-show-part-button-type\r
++ :notmuch-part-hidden nil))\r
+ (insert "\n")\r
+ ;; return button\r
+ button))\r
+@@ -493,20 +494,22 @@ message at DEPTH in the current thread."\r
+ (let* ((button (or button (button-at (point))))\r
+ (overlay (button-get button 'overlay)))\r
+ (when overlay\r
+- (let* ((show (overlay-get overlay 'invisible))\r
++ (let* ((show (button-get button :notmuch-part-hidden))\r
+ (new-start (button-start button))\r
+ (button-label (button-get button :base-label))\r
+ (old-point (point))\r
+ (properties (text-properties-at (point)))\r
+ (inhibit-read-only t))\r
+- (overlay-put overlay 'invisible (not show))\r
++ ;; Toggle the button itself.\r
++ (button-put button :notmuch-part-hidden (not show))\r
+ (goto-char new-start)\r
+ (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
+ (set-text-properties new-start (point) properties)\r
+ (let ((old-end (button-end button)))\r
+ (move-overlay button new-start (point))\r
+ (delete-region (point) old-end))\r
+- (goto-char (min old-point (1- (button-end button))))))))\r
++ (goto-char (min old-point (1- (button-end button))))\r
++ (overlay-put overlay 'invisible (not show))))))\r
+ \r
+ ;; MIME part renderers\r
+ \r
+@@ -793,7 +796,7 @@ message at DEPTH in the current thread."\r
+ (setq handlers (cdr handlers))))\r
+ t)\r
+ \r
+-(defun notmuch-show-create-part-overlays (button beg end hide)\r
++(defun notmuch-show-create-part-overlays (button beg end)\r
+ "Add an overlay to the part between BEG and END"\r
+ \r
+ ;; If there is no button (i.e., the part is text/plain and the first\r
+@@ -801,11 +804,8 @@ message at DEPTH in the current thread."\r
+ ;; toggleable.\r
+ (when (and button (/= beg end))\r
+ (button-put button 'overlay (make-overlay beg end))\r
+- ;; We toggle the button for hidden parts as that gets the\r
+- ;; button label right.\r
+- (save-excursion\r
+- (when hide\r
+- (notmuch-show-toggle-part-invisibility button)))))\r
++ ;; Return true if we created an overlay.\r
++ t))\r
+ \r
+ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
+ "Insert the body part PART at depth DEPTH in the current thread.\r
+@@ -832,7 +832,10 @@ If HIDE is non-nil then initially hide this part."\r
+ ;; Ensure that the part ends with a carriage return.\r
+ (unless (bolp)\r
+ (insert "\n"))\r
+- (notmuch-show-create-part-overlays button content-beg (point) hide)\r
++ (notmuch-show-create-part-overlays button content-beg (point))\r
++ (when hide\r
++ (save-excursion\r
++ (notmuch-show-toggle-part-invisibility button)))\r
+ ;; Record part information. Since we already inserted subparts,\r
+ ;; don't override existing :notmuch-part properties.\r
+ (notmuch-map-text-property beg (point) :notmuch-part\r
+-- \r
+1.7.9.1\r
+\r