--- /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 45399431FDA\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Sep 2013 00:30:54 -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 THg6k78O1woo for <notmuch@notmuchmail.org>;\r
+ Wed, 4 Sep 2013 00:30:46 -0700 (PDT)\r
+Received: from mail-we0-f169.google.com (mail-we0-f169.google.com\r
+ [74.125.82.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A0184431FD6\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Sep 2013 00:30:46 -0700 (PDT)\r
+Received: by mail-we0-f169.google.com with SMTP id t60so2722195wes.14\r
+ for <notmuch@notmuchmail.org>; Wed, 04 Sep 2013 00:30:45 -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:in-reply-to:references;\r
+ bh=J4O/DGESME/MKahpYp+iQONiDfBRAOh7E0C6lZ1Xs7s=;\r
+ b=A5qxVegfNHgdsDqNdqyoGKqor+Ojh+BI6IlqMI7L0iEHjtUe1HbXJULKbLLPkm5NAC\r
+ eEn1UwlZL/7hJZfN7w9VUisnEELqv/J7l7mOYjkUi1TVql6hIJ/XVoipPy+rQyhIsOQ7\r
+ VsCqrhFb5uh/CixY3rYpWAZkDw11FYTOelHxCxCU27+SHEUcF+q2gvNbfM10H6fVvLnH\r
+ 3iqYoKrWD+zGDtcF4C+//Ruh7p3q2ti0DpdLe4A0lZGtzxD7ScEJJIiqj+n3AZ1VCHK1\r
+ ck4g93t+YHtSxJFzW38CzTx8hNWB37e2Hk4pSh5dOerD2659uBbUG2nMzEsSEqNC9JqM\r
+ 8KPA==\r
+X-Received: by 10.194.93.105 with SMTP id ct9mr1262100wjb.6.1378279844029;\r
+ Wed, 04 Sep 2013 00:30:44 -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 i12sm1795773wiw.3.1969.12.31.16.00.00\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Wed, 04 Sep 2013 00:30:43 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: show: lazy part bugfix\r
+Date: Wed, 4 Sep 2013 08:30:35 +0100\r
+Message-Id: <1378279835-28288-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1377246875-7784-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1377246875-7784-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: Wed, 04 Sep 2013 07:30:54 -0000\r
+\r
+The lazy part handling had a subtle bug. Notmuch stores the part\r
+information as a text property with the displayed part so attachment\r
+handling (saving viewing etc work).\r
+\r
+Now, some mime parts have subparts and to avoid overwriting the\r
+sub-part data notmuch checks and if part data is already recorded it\r
+does not overwrite it.\r
+\r
+Now with lazy part handling this could fail: there is already part\r
+data stored. In the common case it works as the part type information\r
+was stored when the lazy-part button was inserted. However, this fails\r
+if the lazy part has sub-parts: notmuch had no idea these existed\r
+until the lazy part insertion.\r
+\r
+We fix this by removing any existing part-information from the\r
+relevant region before doing the lazy insertion.\r
+---\r
+This is the same as the previous patch\r
+id:1377246875-7784-1-git-send-email-markwalters1009@gmail.com except I\r
+have added a substantial comment. I now believe the +1 in the remove\r
+part information is genuinely correct for the reason detailed in the comment.\r
+ \r
+This does seem to fix an actual bug (see parent message and links there).\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+ emacs/notmuch-show.el | 13 +++++++++++++\r
+ 1 files changed, 13 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 20844f0..58ef4df 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -852,7 +852,20 @@ message at DEPTH in the current thread."\r
+ ;; from a message header etc) so instead we start from the last\r
+ ;; character of the button by adding a newline and finish by\r
+ ;; removing the extra newline from the end of the part.\r
++ ;;\r
++ ;; Essentially, this function wants text properties to be\r
++ ;; front-nonsticky (where most of the other functions need\r
++ ;; front-sticky so that is what they actually are) and this is a way\r
++ ;; of faking the front-nonsticky for this one function.\r
++ ;;\r
++ ;; For exactly this reason we also remove existing part-information\r
++ ;; from one extra character: this extra character is the newline\r
++ ;; that we delete at the end.\r
++\r
+ (save-excursion\r
++ ;; Remove part-information from lazy part-region\r
++ (put-text-property (button-start button) (1+ (button-end button)) :notmuch-part nil)\r
++\r
+ (goto-char (button-end button))\r
+ (insert "\n")\r
+ (let* ((inhibit-read-only t)\r
+-- \r
+1.7.9.1\r
+\r