--- /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 4CB14429E32\r
+ for <notmuch@notmuchmail.org>; Fri, 31 May 2013 11:27:52 -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 gVTbjmb7Hh0B for <notmuch@notmuchmail.org>;\r
+ Fri, 31 May 2013 11:27:46 -0700 (PDT)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+ [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id BAAF0429E34\r
+ for <notmuch@notmuchmail.org>; Fri, 31 May 2013 11:27:26 -0700 (PDT)\r
+Received: by mail-wi0-f181.google.com with SMTP id hi5so962562wib.14\r
+ for <notmuch@notmuchmail.org>; Fri, 31 May 2013 11:27: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=NzwqXnMZ2smnb1/JhTNQRyJO1YLCnbUlj0bBHWuMpiM=;\r
+ b=N3NWsDqWOHFpBCCPN3Oto3xIUpS24sF1qhW9V4EWdcbJWTUmjrMRwIm8uSA7bj7PQ2\r
+ Nm2ZhfKSPe3xBv2CaAURqbQkF+t2vi3kvQAZYH6xtEGtvlqF4he2R7VZd7pSN5NWGsg5\r
+ B/UDpFl1W8tlDYiQBU3iw7152Ei5xJ+tGZLOLueN/H1XOGlfRBe8z8AcTXlyxBqv+lxW\r
+ 9+IDDgLbU/+mtj71g+gp+fSXLh1GIrQk35+mfLiLoFVNwSF77pM/YZ7eFDApeTkMevlH\r
+ Fhc2psYESe4d8WsHWb9+E/lUCTH+qssPB6nsv2NDVVdb+JrS5/HtCeM1UoZT9pAjMpKT\r
+ 0W2g==\r
+X-Received: by 10.180.206.77 with SMTP id lm13mr4448242wic.18.1370024845601;\r
+ Fri, 31 May 2013 11:27:25 -0700 (PDT)\r
+Received: from localhost (92.40.240.237.threembb.co.uk. [92.40.240.237])\r
+ by mx.google.com with ESMTPSA id d5sm5742397wic.1.2013.05.31.11.27.23\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Fri, 31 May 2013 11:27:25 -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 v3 4/5] emacs: show: modify the way hidden state is recorded.\r
+Date: Fri, 31 May 2013 19:26:45 +0100\r
+Message-Id: <1370024806-6616-5-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1370024806-6616-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: Fri, 31 May 2013 18:27:52 -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 | 23 +++++++++++++----------\r
+ 1 file changed, 13 insertions(+), 10 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 66cc3a5..89199e8 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -495,6 +495,7 @@ message at DEPTH in the current thread."\r
+ (concat "[ " base-label " ]")\r
+ :base-label base-label\r
+ :type 'notmuch-show-part-button-type\r
++ :notmuch-part-hidden nil\r
+ :notmuch-part nth\r
+ :notmuch-filename name\r
+ :notmuch-content-type content-type))\r
+@@ -555,18 +556,20 @@ 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
+ (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
+ (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
+ (defun notmuch-show-multipart/*-to-list (part)\r
+ (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
+@@ -851,7 +854,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
+@@ -859,11 +862,9 @@ 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
+ \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
+@@ -889,7 +890,9 @@ 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 beg (point) hide)))\r
++ (notmuch-show-create-part-overlays button beg (point))\r
++ (when hide\r
++ (notmuch-show-toggle-part-invisibility button))))\r
+ \r
+ (defun notmuch-show-insert-body (msg body depth)\r
+ "Insert the body BODY at depth DEPTH in the current thread."\r
+-- \r
+1.7.10.4\r
+\r