--- /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 E0A4B421161\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Jun 2013 01:16:43 -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 jaukW1m-cJnV for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Jun 2013 01:16:38 -0700 (PDT)\r
+Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com\r
+ [74.125.82.52]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 28948429E4A for <notmuch@notmuchmail.org>; Sat, 1 Jun 2013 01:16:29 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f52.google.com with SMTP id z11so1826154wgg.31\r
+ for <notmuch@notmuchmail.org>; Sat, 01 Jun 2013 01:16:28 -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=4q8vYTjj6cSSpMm8tbxmfihn6ZTJQ+5sN2EcIJY+81g=;\r
+ b=1A75/YcuktELBk/y4YmF1ZeNVkdXz20XEiLceEKoNwQ6O/mM4ddbV4oeVyDXGfFekL\r
+ 1n6NLzYcz2l4BPbXDoLhnpVQRTrUi25rtotF6XWROYXX/Hcm63QAtB8V0q7S+4gs31SH\r
+ +R/MZ1JQJV/DJKEWT6CSO9UxdUcEsmvc5YU7Kj7myAyL5UZJYcCaaAHthSlHs9aMZ3SB\r
+ vgyRCkBFtAKs/Ek88hnB3bdsdowbWHQvMQKaBMn8ToNrSrS5Ehah73MgGw76vFSyfvLW\r
+ yERrlw1TOHgAx1oKW1ApRG/RYOEvdRxtOcnCrTF8dwu5ZqnmiIlSxcZBaF5RcamDSk4E\r
+ cXdQ==\r
+X-Received: by 10.194.238.42 with SMTP id vh10mr1757357wjc.28.1370074588082;\r
+ Sat, 01 Jun 2013 01:16:28 -0700 (PDT)\r
+Received: from localhost (94.197.247.227.threembb.co.uk. [94.197.247.227])\r
+ by mx.google.com with ESMTPSA id d5sm8657346wic.1.2013.06.01.01.16.25\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 01 Jun 2013 01:16:27 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org, Austin Clements <aclements@csail.mit.edu>,\r
+ Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+Subject: [PATCH v4 4/5] emacs: show: modify the way hidden state is recorded.\r
+Date: Sat, 1 Jun 2013 09:15:46 +0100\r
+Message-Id: <1370074547-24677-5-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1370074547-24677-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1370074547-24677-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: Sat, 01 Jun 2013 08:16:44 -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 file changed, 14 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index cdea271..49f85ba 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.10.4\r
+\r