--- /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 A0E66429E4F\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Jun 2013 01:16:31 -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 5SI+w+cxvs5q for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Jun 2013 01:16:27 -0700 (PDT)\r
+Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com\r
+ [209.85.212.178]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 2CE2A429E44\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Jun 2013 01:16:24 -0700 (PDT)\r
+Received: by mail-wi0-f178.google.com with SMTP id hj6so1312770wib.5\r
+ for <notmuch@notmuchmail.org>; Sat, 01 Jun 2013 01:16:23 -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=gsmea6u0kF/sVUJeDYXtG+76vfG0wv+59X6iK7hJTw8=;\r
+ b=jcBcp0N3dPDWiSyQrjZ6pfm0A7VD0mFqY67j+nlGjSsA1eyZy3o0BXGrQP8G6uawK2\r
+ RnaEAD5wWV6LROfR3QVURpe/kgkxQcEkuD2NwW15WY8kDncEgEJGBP2h29tWpknjWdfZ\r
+ xEqjYXX8AEM4oFvXa2LHu4yLxYLs8gAdeUx5BB3gx0VlMDOFCbikfHpUJstsWG/aRLuP\r
+ qnTQfP0OlCPpb6bVi6L076A6gVfuV51DsVoKXG5Bq2OjXNwSQ8T3XPjxoNPJyKtfLHNp\r
+ 0sYxi8Mxt22MIROwfjCvsiW2ah+DX6T1iKPqBcz4kSniak6ucDJdXjEakqZLikDu5WrU\r
+ O8Hw==\r
+X-Received: by 10.194.104.105 with SMTP id gd9mr12431695wjb.1.1370074583085;\r
+ Sat, 01 Jun 2013 01:16:23 -0700 (PDT)\r
+Received: from localhost (94.197.247.227.threembb.co.uk. [94.197.247.227])\r
+ by mx.google.com with ESMTPSA id d5sm8657105wic.1.2013.06.01.01.16.20\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 01 Jun 2013 01:16:22 -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 v4 3/5] emacs: show: pass button to create-overlays\r
+Date: Sat, 1 Jun 2013 09:15:45 +0100\r
+Message-Id: <1370074547-24677-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1370074547-24677-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1370074547-24677-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: Sat, 01 Jun 2013 08:16:31 -0000\r
+\r
+Now that the bodypart code has the button we can pass that to\r
+create-overlays and simplify that.\r
+---\r
+ emacs/notmuch-show.el | 31 +++++++++++++++----------------\r
+ 1 file changed, 15 insertions(+), 16 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 9e119e8..cdea271 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -793,21 +793,19 @@ message at DEPTH in the current thread."\r
+ (setq handlers (cdr handlers))))\r
+ t)\r
+ \r
+-(defun notmuch-show-create-part-overlays (msg beg end hide)\r
++(defun notmuch-show-create-part-overlays (button beg end hide)\r
+ "Add an overlay to the part between BEG and END"\r
+- (let* ((button (button-at beg))\r
+- (part-beg (and button (1+ (button-end button)))))\r
+-\r
+- ;; If the part contains no text we do not make it toggleable. We\r
+- ;; also need to check that the button is a genuine part button not\r
+- ;; a notmuch-wash button.\r
+- (when (and button (/= part-beg end) (button-get button :base-label))\r
+- (button-put button 'overlay (make-overlay part-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
++\r
++ ;; If there is no button (i.e., the part is text/plain and the first\r
++ ;; part) or if the part has no content then we don't make the part\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
+ \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
+@@ -824,7 +822,8 @@ If HIDE is non-nil then initially hide this part."\r
+ (beg (point))\r
+ ;; We omit the part button for the first (or only) part if this is text/plain.\r
+ (button (unless (and (string= mime-type "text/plain") (<= nth 1))\r
+- (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))))\r
++ (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
++ (content-beg (point)))\r
+ \r
+ (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)\r
+ ;; Some of the body part handlers leave point somewhere up in the\r
+@@ -833,7 +832,7 @@ 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 msg beg (point) hide)\r
++ (notmuch-show-create-part-overlays button content-beg (point) hide)\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
+-- \r
+1.7.10.4\r
+\r