--- /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 11A86431FD5\r
+ for <notmuch@notmuchmail.org>; Thu, 30 May 2013 16:28:31 -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 kZ1Q8rkpxN42 for <notmuch@notmuchmail.org>;\r
+ Thu, 30 May 2013 16:28:25 -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 5DB58431FC3\r
+ for <notmuch@notmuchmail.org>; Thu, 30 May 2013 16:28:25 -0700 (PDT)\r
+X-AuditID: 1209190e-b7f4f6d000005142-07-51a7e0964e45\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 38.F7.20802.690E7A15; Thu, 30 May 2013 19:28:22 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r4UNSLk6011926; \r
+ Thu, 30 May 2013 19:28:22 -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 r4UNSJbA030419\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Thu, 30 May 2013 19:28:20 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1UiCGZ-0006Bb-07; Thu, 30 May 2013 19:28:19 -0400\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 3/3] emacs: show: implement lazy hidden part handling\r
+In-Reply-To: <1369555061-21361-4-git-send-email-markwalters1009@gmail.com>\r
+References: <1369555061-21361-1-git-send-email-markwalters1009@gmail.com>\r
+ <1369555061-21361-4-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: Thu, 30 May 2013 19:28:18 -0400\r
+Message-ID: <877gig2gkt.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsUixG6nrjvtwfJAg8Xn5SxWz+WxuH5zJrMD\r
+ k8fOWXfZPZ6tusUcwBTFZZOSmpNZllqkb5fAlbGvu42x4L1Kxbo3k1gbGKfJdjFyckgImEj8\r
+ W/6NFcIWk7hwbz1bFyMXh5DAPkaJgy8fMkM4Gxklnpz/zwrhnGaS2Ln6PRtIi5DAEkaJz+sz\r
+ QWw2AX2JFWsngY0SEXCVePrtMzOILSzgIzF72mawOKeAl8ST1ScYIQa1M0qcudLFCJIQFUiQ\r
+ WHn3BJjNIqAq8eHCbbBmXqD7Hl55ywphC0qcnPmEBcRmFtCSuPHvJdMERoFZSFKzkKQWMDKt\r
+ YpRNya3SzU3MzClOTdYtTk7My0st0jXWy80s0UtNKd3ECApJTkm+HYxfDyodYhTgYFTi4c1I\r
+ Wh4oxJpYVlyZe4hRkoNJSZT3zT2gEF9SfkplRmJxRnxRaU5q8SFGCQ5mJRHeznNAOd6UxMqq\r
+ 1KJ8mJQ0B4uSOO+VlJv+QgLpiSWp2ampBalFMFkZDg4lCd7m+0CNgkWp6akVaZk5JQhpJg5O\r
+ kOE8QMNXgtTwFhck5hZnpkPkTzEqSonzzgBJCIAkMkrz4HphKeMVozjQK8K8tSBVPMB0A9f9\r
+ CmgwE9DgJ9Zgg0sSEVJSDYwy1Sw7ohdfDlUPT7pzr/XCLWvVdeGc7vo6M1dJR18KLzs1q6Wu\r
+ uUPD7fZn/gbmnh1fui63eATUijv2Hd1sL3Z1to3f+S2TTiXn8b5LPGazbqsNQ9v+dV3vPu6M\r
+ MfN7VzU3pMNAV7M27/rvCTVd4qaxGx9vyS6a21Jm+/jiJaGEjzvf/r/dWqDEUpyRaKjFXFSc\r
+ CAAohjxI9AIAAA==\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: Thu, 30 May 2013 23:28:31 -0000\r
+\r
+On Sun, 26 May 2013, Mark Walters <markwalters1009@gmail.com> wrote:\r
+> This adds the actual code to do the lazy insertion of hidden parts.\r
+>\r
+> We use a memory inefficient but simple method: when we come to insert\r
+> the part if it is hidden we just store all of the arguments to the\r
+> part insertion function as a button property. This means when we want\r
+> to show the part we can just resume where we left off.\r
+>\r
+> The only slight subtlety/hack is that to simplify the handling of the\r
+> invisibility overlay (for the hiding unhiding later) we do insert some\r
+> dummy text which we remove when we show the part.\r
+> ---\r
+> emacs/notmuch-show.el | 32 ++++++++++++++++++++++++++++++--\r
+> 1 files changed, 30 insertions(+), 2 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index 591ad56..94faa9b 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -560,6 +560,7 @@ message at DEPTH in the current thread."\r
+> (overlay (button-get button 'overlay)))\r
+> (when overlay\r
+> (let* ((show (overlay-get overlay 'invisible))\r
+> + (lazy-part (button-get button :notmuch-lazy-part))\r
+> (new-start (button-start button))\r
+> (button-label (button-get button :base-label))\r
+> (old-point (point))\r
+> @@ -570,7 +571,11 @@ message at DEPTH in the current thread."\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
+> + (when (and show lazy-part)\r
+> + (save-excursion\r
+> + (button-put button :notmuch-lazy-part nil)\r
+> + (notmuch-show-lazy-part lazy-part button)))))))\r
+> \r
+> (defun notmuch-show-multipart/*-to-list (part)\r
+> (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
+> @@ -854,6 +859,24 @@ message at DEPTH in the current thread."\r
+> (setq handlers (cdr handlers))))\r
+> t)\r
+> \r
+> +(defun notmuch-show-lazy-part (part-args button)\r
+> + (interactive)\r
+> + ;; We have to save the depth as we can't find the depth when narrowed\r
+> + (let ((inhibit-read-only t)\r
+> + (overlay (button-get button 'overlay))\r
+> + (depth (notmuch-show-get-depth)))\r
+> + (save-restriction\r
+> + (narrow-to-region (overlay-start overlay) (1- (overlay-end overlay)))\r
+> + (delete-region (overlay-start overlay) (1- (overlay-end overlay)))\r
+> + (goto-char (overlay-start overlay))\r
+> + (apply #'notmuch-show-insert-bodypart-internal (nconc part-args (list button)))\r
+\r
+Is there a reason 'button' couldn't be included in parts-args when\r
+parts-args was originally constructed below? (If so, then this probably\r
+deserves a comment.)\r
+\r
+> + (indent-rigidly (overlay-start overlay)\r
+> + (1- (overlay-end overlay))\r
+> + depth))\r
+> + ;; We deferred deleting this character to simplify handling of the\r
+> + ;; overlay: all of the above takes place inside the overlay.\r
+> + (delete-region (1- (overlay-end overlay)) (overlay-end overlay))))\r
+> +\r
+> (defun notmuch-show-create-part-overlays (msg beg end hide)\r
+> "Add an overlay to the part between BEG and END"\r
+> (let* ((button (button-at beg))\r
+> @@ -888,7 +911,12 @@ If HIDE is non-nil then initially hide this part."\r
+> (button (unless (string= mime-type "text/plain")\r
+> (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))))\r
+> \r
+> - (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type button)\r
+> + (if (not hide)\r
+> + (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type button)\r
+> + (insert "lazy part")\r
+\r
+The insert is worth a comment. Or fixing if it's not too difficult.\r
+\r
+> + (button-put button :notmuch-lazy-part\r
+> + (list msg part mime-type nth depth content-type)))\r
+> +\r
+\r
+To summarize the IRC discussion for the record, this changes the\r
+behavior of lazily inserted parts that we can't render. Currently the\r
+only way we know if we can render a part is by attempting to render it.\r
+As a result, lazily inserted parts that we can't render that would\r
+previously have offered to save the part when the part button was\r
+selected will now attempt to render the part and simply not display\r
+anything.\r
+\r
+> ;; Some of the body part handlers leave point somewhere up in the\r
+> ;; part, so we make sure that we're down at the end.\r
+> (goto-char (point-max))\r
+> -- \r
+> 1.7.9.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r