--- /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 C67E1431FBF\r
+ for <notmuch@notmuchmail.org>; Sun, 9 Jun 2013 21:57:27 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.7\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.7 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
+ FREEMAIL_REPLY=2.499, 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 6pMkc19OWKhP for <notmuch@notmuchmail.org>;\r
+ Sun, 9 Jun 2013 21:57:20 -0700 (PDT)\r
+Received: from mail-ea0-f170.google.com (mail-ea0-f170.google.com\r
+ [209.85.215.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 15652431FAE\r
+ for <notmuch@notmuchmail.org>; Sun, 9 Jun 2013 21:57:19 -0700 (PDT)\r
+Received: by mail-ea0-f170.google.com with SMTP id h10so5014610eaj.15\r
+ for <notmuch@notmuchmail.org>; Sun, 09 Jun 2013 21:57:17 -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;\r
+ bh=nebVvu2+QLVdCUIZaU3L9DDfnxzPhjgM8j00rvMrUQE=;\r
+ b=Gf4HFEBJm6aMRRGxAMdGs4tCOURmsYZYGcPs38mnO4U6nG9NeJm2y7rU2ZJpm0F16y\r
+ vRho0//E89IKdoti8TZE3nmZgME0jStxNe0U9kXSDoulF8QJ/UfoJMGtOgx88sLPXtdZ\r
+ xHVKqVPPvej3jguBi6QtgiVuqNq6Zx9NJA6HgrSrODi70JOnPVJHkc6A640YCXaMHBcI\r
+ OHJVsz3TG97kVvWJmGYO54xZy184KX95JJPlBPDRMRSB/MGfehvyLE4akzxYqx003No2\r
+ jJZ7fDQCl/WP1JsuU3atMEPw0lM4aB3hLqTIwfV1jGWuN7Pt4EhIkP3X9qrqyzNPO4hw\r
+ aWuA==\r
+X-Received: by 10.15.48.129 with SMTP id h1mr8962712eew.65.1370840237502;\r
+ Sun, 09 Jun 2013 21:57:17 -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 3sm20257273een.7.2013.06.09.21.57.16\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 09 Jun 2013 21:57:16 -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 0/6] emacs: show: lazy handling of hidden parts\r
+Date: Mon, 10 Jun 2013 05:57:07 +0100\r
+Message-Id: <1370840233-23258-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\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:28 -0000\r
+\r
+This is version 5 of this patch set. Version 4 is at\r
+id:1370074547-24677-1-git-send-email-markwalters1009@gmail.com.\r
+\r
+This version fixes the two bugs pointed out in Austin's review\r
+id:20130610023952.GC22196@mit.edu.\r
+\r
+I decided to add the :notmuch-part text property separately from\r
+create-overlays as they have slightly different regions (one includes\r
+the button one does not) and are applied at slightly different times\r
+(we do not create overlays for lazy parts).\r
+\r
+I was not sure whether we created two overlays for hidden lazy parts\r
+in v4 (it might not have done as the part was empty and we do not\r
+create overlays for empty parts) but that is stupidly fragile. Thus we\r
+explicitly do not create overlays for lazy parts until they are\r
+inserted.\r
+\r
+The diff from v4 is below.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+Mark Walters (6):\r
+ emacs: show: fake wash parts are handled at insert-bodypart level\r
+ emacs: show: move the insertion of the header button to the top level\r
+ emacs: show: pass button to create-overlays\r
+ emacs: show: modify the way hidden state is recorded.\r
+ emacs: show move addition of :notmuch-part to separate function\r
+ emacs: show: implement lazy hidden part handling\r
+\r
+ emacs/notmuch-show.el | 241 ++++++++++++++++++++++++++++++-------------------\r
+ 1 files changed, 146 insertions(+), 95 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index b963859..d030ea3 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -817,6 +817,27 @@ message at DEPTH in the current thread."\r
+ ;; Return true if we created an overlay.\r
+ t))\r
+ \r
++(defun notmuch-show-record-part-information (part beg end)\r
++ "Store PART as a text property from BEG to END"\r
++\r
++ ;; Record part information. Since we already inserted subparts,\r
++ ;; don't override existing :notmuch-part properties.\r
++ (notmuch-map-text-property beg end :notmuch-part\r
++ (lambda (v) (or v part)))\r
++ ;; Make :notmuch-part front sticky and rear non-sticky so it stays\r
++ ;; applied to the beginning of each line when we indent the\r
++ ;; message. Since we're operating on arbitrary renderer output,\r
++ ;; watch out for sticky specs of t, which means all properties are\r
++ ;; front-sticky/rear-nonsticky.\r
++ (notmuch-map-text-property beg end 'front-sticky\r
++ (lambda (v) (if (listp v)\r
++ (pushnew :notmuch-part v)\r
++ v)))\r
++ (notmuch-map-text-property beg end 'rear-nonsticky\r
++ (lambda (v) (if (listp v)\r
++ (pushnew :notmuch-part v)\r
++ v))))\r
++\r
+ (defun notmuch-show-lazy-part (part-args button)\r
+ ;; Insert the lazy part after the button for the part. We would just\r
+ ;; move to the start of the new line following the button and insert\r
+@@ -843,6 +864,9 @@ message at DEPTH in the current thread."\r
+ (indent-rigidly part-beg part-end depth))\r
+ (goto-char part-end)\r
+ (delete-char 1)\r
++ (notmuch-show-record-part-information (second part-args)\r
++ (button-start button)\r
++ part-end)\r
+ ;; Create the overlay. If the lazy-part turned out to be empty/not\r
+ ;; showable this returns nil.\r
+ (notmuch-show-create-part-overlays button part-beg part-end))))\r
+@@ -876,27 +900,13 @@ 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))\r
+- (when hide\r
++ ;; We do not create the overlay for hidden (lazy) parts until\r
++ ;; they are inserted.\r
++ (if (not hide)\r
++ (notmuch-show-create-part-overlays button content-beg (point))\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
+- (lambda (v) (or v part)))\r
+- ;; Make :notmuch-part front sticky and rear non-sticky so it stays\r
+- ;; applied to the beginning of each line when we indent the\r
+- ;; message. Since we're operating on arbitrary renderer output,\r
+- ;; watch out for sticky specs of t, which means all properties are\r
+- ;; front-sticky/rear-nonsticky.\r
+- (notmuch-map-text-property beg (point) 'front-sticky\r
+- (lambda (v) (if (listp v)\r
+- (pushnew :notmuch-part v)\r
+- v)))\r
+- (notmuch-map-text-property beg (point) 'rear-nonsticky\r
+- (lambda (v) (if (listp v)\r
+- (pushnew :notmuch-part v)\r
+- v)))))\r
++ (notmuch-show-record-part-information part beg (point))))\r
+ \r
+ (defun notmuch-show-insert-body (msg body depth)\r
+ "Insert the body BODY at depth DEPTH in the current thread."\r
+\r
+\r
+-- \r
+1.7.9.1\r
+\r