--- /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 293B0431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Dec 2012 08:47:37 -0800 (PST)\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 MVHHrjhI-qm8 for <notmuch@notmuchmail.org>;\r
+ Mon, 3 Dec 2012 08:47:36 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
+ [18.7.68.35])\r
+ by olra.theworths.org (Postfix) with ESMTP id 8E324431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Dec 2012 08:47:36 -0800 (PST)\r
+X-AuditID: 12074423-b7fcb6d000000927-25-50bcd7a791a2\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 54.94.02343.7A7DCB05; Mon, 3 Dec 2012 11:47:35 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qB3GlYiU029477; \r
+ Mon, 3 Dec 2012 11:47:35 -0500\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.6/8.12.4) with ESMTP id qB3GlVU3009563\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Mon, 3 Dec 2012 11:47:33 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1TfZB4-0002U9-QR; Mon, 03 Dec 2012 11:47:30 -0500\r
+Date: Mon, 3 Dec 2012 11:47:30 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH] emacs: show: refresh buffer did not remove overlays\r
+Message-ID: <20121203164730.GE1020@mit.edu>\r
+References: <1354540260-21814-1-git-send-email-markwalters1009@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1354540260-21814-1-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpkleLIzCtJLcpLzFFi42IR4hRV1l1+fU+AwdRP/Bar5/JYXL85k9mB\r
+ yWPnrLvsHs9W3WIOYIrisklJzcksSy3St0vgyli9JbHgmXDFnJ1b2BoYb/N3MXJySAiYSDze\r
+ 0csOYYtJXLi3nq2LkYtDSGAfo8SPWc+ZIZz1jBLTG6azglQJCVxgkmju04dILGGU6Fswnxkk\r
+ wSKgIvHs4WGwUWwCGhLb9i9nBLFFBHQkbh9aABZnFpCW+Pa7mQnEFhbwkJh/pIUNxOYV0JZY\r
+ MncxE8QCT4nbW3exQMQFJU7OfMIC0aslcePfS6AaDrA5y/9xgIQ5BbwkHnasBVslCnTClJPb\r
+ 2CYwCs1C0j0LSfcshO4FjMyrGGVTcqt0cxMzc4pTk3WLkxPz8lKLdM30cjNL9FJTSjcxgkKa\r
+ 3UV5B+Ofg0qHGAU4GJV4eB982R0gxJpYVlyZe4hRkoNJSZT3+Zk9AUJ8SfkplRmJxRnxRaU5\r
+ qcWHGCU4mJVEeHduBMrxpiRWVqUW5cOkpDlYlMR5r6Xc9BcSSE8sSc1OTS1ILYLJynBwKEnw\r
+ tl4DahQsSk1PrUjLzClBSDNxcIIM5wEa/uQqyPDigsTc4sx0iPwpRkUpcd6DIAkBkERGaR5c\r
+ LyzlvGIUB3pFmPcYSBUPMF3Bdb8CGswENPiF0G6QwSWJCCmpBkbuG2bnVsyYvKFr3+Hdp3I2\r
+ z69evr6gcCn7hOspLXnbPqpbaHolBqs1h7x/HNYoeqyqWXfihJfHGuc3NJdfDWd6xyj+0Xra\r
+ udjNh58/m+VgfTsm6V/3y1/Pb2/byRT/JbCeI1ZQUsBS8KuV8z1nG5d5f36ciSstf61mev3Q\r
+ ncZ38/e5POlZYhWtxFKckWioxVxUnAgACfehuBQDAAA=\r
+Cc: notmuch@notmuchmail.org\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, 03 Dec 2012 16:47:37 -0000\r
+\r
+Quoth Mark Walters on Dec 03 at 1:11 pm:\r
+> Previously refreshing the notmuch show buffer did not remove overlays\r
+> which meant that if the user refreshed a message with images the\r
+> images would remain and then the new text was added after.\r
+> \r
+> One might have guessed that erase-buffer would have removed them but\r
+> it seems not. Thus force the removal of overlays with remove-overlay.\r
+> ---\r
+> The new toggle-parts code makes this bug much more likely to trigger\r
+> (as the user is quite likely to toggle a part in a message with an\r
+> image). However, it was already present if anyone tried refreshing a\r
+> show buffer with an image in it.\r
+> \r
+> It would be good if someone could check whether there is anything else\r
+> that also needs to be manually removed. But, for me at least, this\r
+> seems to fix the problem.\r
+> \r
+> Many thanks to Jani for finding the bug and helping with the diagnosis.\r
+\r
+>From the source for erase-buffer it's clear that it is not intended to\r
+delete non-evaporating overlays (and overlays are non-evaporating by\r
+default).\r
+\r
+AFAIK, the only other things that stick around are buffer-local\r
+variables (which we clear in notmuch-show-refresh-view ->\r
+notmuch-show-build-buffer -> notmuch-show-mode) and markers.\r
+\r
+> Best wishes\r
+> \r
+> Mark\r
+> \r
+> \r
+> \r
+> \r
+> emacs/notmuch-show.el | 3 +++\r
+> 1 files changed, 3 insertions(+), 0 deletions(-)\r
+> \r
+> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> index c8c1657..e89dba2 100644\r
+> --- a/emacs/notmuch-show.el\r
+> +++ b/emacs/notmuch-show.el\r
+> @@ -1214,6 +1214,9 @@ reset based on the original query."\r
+> (setq notmuch-show-message-multipart/alternative-display-parts nil)\r
+> (notmuch-show-capture-state))))\r
+> (erase-buffer)\r
+\r
+This isn't exactly related to your patch, but it looks like\r
+notmuch-show-build-buffer also calls erase-buffer, so I wonder if this\r
+is redundant.\r
+\r
+> + ;; erase-buffer does not seem to remove overlays so do it manually.\r
+> + ;; This can lead to weird effects such as remaining images.\r
+\r
+I parse this as "Doing this manually can lead to weird effects...".\r
+Maybe\r
+\r
+erase-buffer does not seem to remove overlays, which can lead to weird\r
+effects such as remaining images, so remove them manually.\r
+\r
+?\r
+\r
+> + (remove-overlays)\r
+\r
+For performance, it's probably slightly better to do this before the\r
+erase-buffer so that erase-buffer doesn't have to shift around the\r
+overlays.\r
+\r
+> (notmuch-show-build-buffer)\r
+> (if state\r
+> (notmuch-show-apply-state state)\r