--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 9349A431FD6\r
+ for <notmuch@notmuchmail.org>; Fri, 31 May 2013 16:09:53 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 QsN4opE4px8Y for <notmuch@notmuchmail.org>;\r
+ Fri, 31 May 2013 16:09:47 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
+ [18.9.25.14])\r
+ by olra.theworths.org (Postfix) with ESMTP id 424E6431FBD\r
+ for <notmuch@notmuchmail.org>; Fri, 31 May 2013 16:09:47 -0700 (PDT)\r
+X-AuditID: 1209190e-b7f4f6d000005142-78-51a92db9d25a\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 98.3B.20802.9BD29A15; Fri, 31 May 2013 19:09:45 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r4VN9iDU001529; \r
+ Fri, 31 May 2013 19:09:44 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4VN9gQb027710\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Fri, 31 May 2013 19:09:43 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1UiYS6-00059K-82; Fri, 31 May 2013 19:09:42 -0400\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org,\r
+ Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+Subject: Re: [PATCH v3 4/5] emacs: show: modify the way hidden state is\r
+ recorded.\r
+In-Reply-To: <1370024806-6616-5-git-send-email-markwalters1009@gmail.com>\r
+References: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com>\r
+ <1370024806-6616-5-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.15.2+83~g8bee3c4 (http://notmuchmail.org) Emacs/23.4.1\r
+ (i486-pc-linux-gnu)\r
+Date: Fri, 31 May 2013 19:09:42 -0400\r
+Message-ID: <871u8m3fwp.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFvrBIsWRmVeSWpSXmKPExsUixCmqrLtTd2WgwdKPOhZH9sxit1g9l8fi\r
+ +s2ZzA7MHjtn3WX3eLbqFrNH04/FrAHMUVw2Kak5mWWpRfp2CVwZ63cvZSuYrFwx+clfpgbG\r
+ +9JdjJwcEgImEi9mL2KCsMUkLtxbz9bFyMUhJLCPUeJw+0woZyOjxI8nz5khnNNMEpf6njBB\r
+ OEsYJTp2XGQH6WcT0JdYsXYSK4gtIlAmsWX6LLC5zAI6Eid2b2MEsYUFAiUeTd8JVsMp4Cnx\r
+ Z8J6qEGtjBKN67uYQRKiAgkSK++eAGtgEVCVuHr0IQuIzQt07Im325ghbEGJkzOfsEAs0JK4\r
+ 8e8l0wRGwVlIUrOQpBYwMq1ilE3JrdLNTczMKU5N1i1OTszLSy3SNdbLzSzRS00p3cQIDmBJ\r
+ vh2MXw8qHWIU4GBU4uE1WLEiUIg1say4MvcQoyQHk5Iob736ykAhvqT8lMqMxOKM+KLSnNTi\r
+ Q4wSHMxKIrz5c4DKeVMSK6tSi/JhUtIcLErivFdSbvoLCaQnlqRmp6YWpBbBZGU4OJQkeA/r\r
+ AA0VLEpNT61Iy8wpQUgzcXCCDOcBGv4YpIa3uCAxtzgzHSJ/ilFRSpz3DkhCACSRUZoH1wtL\r
+ MK8YxYFeEeZ9ClLFA0xOcN2vgAYzAQ1+Yr0cZHBJIkJKqoEx0mG1rpH3lS9vC+YEyF4T2PR6\r
+ QeyrY0VznRhUhfm/dZ7/8uTa24v/enqSb/JXS1YmmGjHmgW5h6uG5K1cNreNsefVkebKvoDN\r
+ Cn32/5yvWqeGfdigc9TETkB9jqr45a2WGbtPfFh2X133QPu3X1dmfJN5HpAjMks8ca1WGsOn\r
+ qjXrg1oWXstXYinOSDTUYi4qTgQAQp1/aAsDAAA=\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 23:09:53 -0000\r
+\r
+On Fri, 31 May 2013, Mark Walters <markwalters1009@gmail.com> wrote:\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
+Ah, I see the mis-indentation was only temporary.\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
+This lost the save-excursion around\r
+notmuch-show-toggle-part-invisibility. I'm surprised that works, given\r
+how notmuch-show-toggle-part-invisibility moves point, but then again, I\r
+can believe that the planets happen to align here because you're hiding\r
+a part and that part happens to go to (point-max). Might be worth a\r
+comment or putting back the save-excursion just so people don't have to\r
+think about it.\r
+\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