From 416d9104a4cf475e84aafedfeaff8d344cabc5c9 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Wed, 4 Sep 2013 08:30:35 +0100 Subject: [PATCH] [PATCH v2] emacs: show: lazy part bugfix --- ad/290f87a53243f5bacd14e241be72d8e6e2eb10 | 122 ++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 ad/290f87a53243f5bacd14e241be72d8e6e2eb10 diff --git a/ad/290f87a53243f5bacd14e241be72d8e6e2eb10 b/ad/290f87a53243f5bacd14e241be72d8e6e2eb10 new file mode 100644 index 000000000..3072f80ce --- /dev/null +++ b/ad/290f87a53243f5bacd14e241be72d8e6e2eb10 @@ -0,0 +1,122 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 45399431FDA + for ; Wed, 4 Sep 2013 00:30:54 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.7 +X-Spam-Level: ** +X-Spam-Status: No, score=2.7 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + FREEMAIL_REPLY=2.499, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id THg6k78O1woo for ; + Wed, 4 Sep 2013 00:30:46 -0700 (PDT) +Received: from mail-we0-f169.google.com (mail-we0-f169.google.com + [74.125.82.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id A0184431FD6 + for ; Wed, 4 Sep 2013 00:30:46 -0700 (PDT) +Received: by mail-we0-f169.google.com with SMTP id t60so2722195wes.14 + for ; Wed, 04 Sep 2013 00:30:45 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=J4O/DGESME/MKahpYp+iQONiDfBRAOh7E0C6lZ1Xs7s=; + b=A5qxVegfNHgdsDqNdqyoGKqor+Ojh+BI6IlqMI7L0iEHjtUe1HbXJULKbLLPkm5NAC + eEn1UwlZL/7hJZfN7w9VUisnEELqv/J7l7mOYjkUi1TVql6hIJ/XVoipPy+rQyhIsOQ7 + VsCqrhFb5uh/CixY3rYpWAZkDw11FYTOelHxCxCU27+SHEUcF+q2gvNbfM10H6fVvLnH + 3iqYoKrWD+zGDtcF4C+//Ruh7p3q2ti0DpdLe4A0lZGtzxD7ScEJJIiqj+n3AZ1VCHK1 + ck4g93t+YHtSxJFzW38CzTx8hNWB37e2Hk4pSh5dOerD2659uBbUG2nMzEsSEqNC9JqM + 8KPA== +X-Received: by 10.194.93.105 with SMTP id ct9mr1262100wjb.6.1378279844029; + Wed, 04 Sep 2013 00:30:44 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id i12sm1795773wiw.3.1969.12.31.16.00.00 + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Wed, 04 Sep 2013 00:30:43 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v2] emacs: show: lazy part bugfix +Date: Wed, 4 Sep 2013 08:30:35 +0100 +Message-Id: <1378279835-28288-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1377246875-7784-1-git-send-email-markwalters1009@gmail.com> +References: <1377246875-7784-1-git-send-email-markwalters1009@gmail.com> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 04 Sep 2013 07:30:54 -0000 + +The lazy part handling had a subtle bug. Notmuch stores the part +information as a text property with the displayed part so attachment +handling (saving viewing etc work). + +Now, some mime parts have subparts and to avoid overwriting the +sub-part data notmuch checks and if part data is already recorded it +does not overwrite it. + +Now with lazy part handling this could fail: there is already part +data stored. In the common case it works as the part type information +was stored when the lazy-part button was inserted. However, this fails +if the lazy part has sub-parts: notmuch had no idea these existed +until the lazy part insertion. + +We fix this by removing any existing part-information from the +relevant region before doing the lazy insertion. +--- +This is the same as the previous patch +id:1377246875-7784-1-git-send-email-markwalters1009@gmail.com except I +have added a substantial comment. I now believe the +1 in the remove +part information is genuinely correct for the reason detailed in the comment. + +This does seem to fix an actual bug (see parent message and links there). + +Best wishes + +Mark + + + emacs/notmuch-show.el | 13 +++++++++++++ + 1 files changed, 13 insertions(+), 0 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 20844f0..58ef4df 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -852,7 +852,20 @@ message at DEPTH in the current thread." + ;; from a message header etc) so instead we start from the last + ;; character of the button by adding a newline and finish by + ;; removing the extra newline from the end of the part. ++ ;; ++ ;; Essentially, this function wants text properties to be ++ ;; front-nonsticky (where most of the other functions need ++ ;; front-sticky so that is what they actually are) and this is a way ++ ;; of faking the front-nonsticky for this one function. ++ ;; ++ ;; For exactly this reason we also remove existing part-information ++ ;; from one extra character: this extra character is the newline ++ ;; that we delete at the end. ++ + (save-excursion ++ ;; Remove part-information from lazy part-region ++ (put-text-property (button-start button) (1+ (button-end button)) :notmuch-part nil) ++ + (goto-char (button-end button)) + (insert "\n") + (let* ((inhibit-read-only t) +-- +1.7.9.1 + -- 2.26.2