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 31D3F429E38 for ; Wed, 4 Sep 2013 07:56:54 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 t4IG10QYpxsx for ; Wed, 4 Sep 2013 07:56:47 -0700 (PDT) Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id 38823429E37 for ; Wed, 4 Sep 2013 07:56:47 -0700 (PDT) X-AuditID: 12074422-b7ef78e000000935-84-52274a2dbe20 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id 8B.54.02357.D2A47225; Wed, 4 Sep 2013 10:56:45 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r84EuiDg020311; Wed, 4 Sep 2013 10:56:45 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r84EufQ7025327 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Wed, 4 Sep 2013 10:56:43 -0400 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) (envelope-from ) id 1VHEVc-00055T-Op; Wed, 04 Sep 2013 10:56:41 -0400 Date: Wed, 4 Sep 2013 10:56:39 -0400 From: Austin Clements To: Mark Walters Subject: Re: [PATCH v2] emacs: show: lazy part bugfix Message-ID: <20130904145639.GB1426@mit.edu> References: <1377246875-7784-1-git-send-email-markwalters1009@gmail.com> <1378279835-28288-1-git-send-email-markwalters1009@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1378279835-28288-1-git-send-email-markwalters1009@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT19X1Ug8yWNyiYrF6Lo/F9ZszmR2Y PHbOusvu8WzVLeYApigum5TUnMyy1CJ9uwSujGNNC9kLPslWnF9V0MB4TbyLkZNDQsBEYt/6 WewQtpjEhXvr2boYuTiEBPYxSvx8NYcJwtnAKHH1TBs7hHOKSeJS63kWCGcJo8Spxplg/SwC KhK7u3qYQGw2AQ2JbfuXM4LYIgI6ErcPLQCrYRaQlvj2uxmsRljAVGL1xDNgcV4BbYlP87ug 1nUwSkxas54VIiEocXLmExaIZi2JG/9eAhVxgA1a/o8DJMwp4CXxdmYTG4gtCnTDlJPb2CYw Cs1C0j0LSfcshO4FjMyrGGVTcqt0cxMzc4pTk3WLkxPz8lKLdE31cjNL9FJTSjcxgsPaRWkH 48+DSocYBTgYlXh4NQ3Vg4RYE8uKK3MPMUpyMCmJ8urZAIX4kvJTKjMSizPii0pzUosPMUpw MCuJ8E51BsrxpiRWVqUW5cOkpDlYlMR5nz09GygkkJ5YkpqdmlqQWgSTleHgUJLgLfIEahQs Sk1PrUjLzClBSDNxcIIM5wEa7gRSw1tckJhbnJkOkT/FqCglzusCkhAASWSU5sH1wtLOK0Zx oFeEIap4gCkLrvsV0GAmoMFpn1VBBpckIqSkGhjjfsvK/bPc+/+CcYjoFfWMdY3fLVoPPDhg sO/Q2ZMux0RXSG30PBn4YK/8wsJ7KcGzt3tvv7k20TGp66mpP8v/wOQrHcGftrxkTnDdxr// vbFMhU61ZEbqRLbw2/HLXVONzA9yn7ryTDfw5uzgObrnBdhq56+c1PJh4TIW9jI1vjNpk2fr 8GUrsRRnJBpqMRcVJwIA4U4JKxYDAAA= Cc: notmuch@notmuchmail.org 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 14:56:54 -0000 Quoth Mark Walters on Sep 04 at 8:30 am: > 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). s/ work)/) 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. This says that things fail when a lazy part has sub-parts, but not what the failure is. What is the failure? Can you give a specific sequence of events and conditions that leads to and demonstrates the failure? (I ask not just for commit posterity, but because I actually don't know, though I may have figured it out after writing the comment below.) > 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. Most properties are rear-sticky and front-nonsticky. Maybe this is referring specifically to :notmuch-part, which is the other way around? > + ;; > + ;; 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. This comment doesn't say what the root of the problem is. Is the following accurate? ;; First, eliminate the :notmuch-part property from the region we'll ;; be inserting this part in, since we never override an existing ;; :notmuch-part property. If we're inserting a leaf part, it will ;; re-apply the same :notmuch-part, but if this isn't a leaf, the ;; children need to apply different :notmuch-part values. ;; :notmuch-part was originally applied to the newline following the ;; button as well, so remove it from that character, too. (If we ;; didn't remove it from the newline, this would all be for naught: ;; :notmuch-part is front-sticky and we insert the part immediately ;; before this newline, so the part would inherit :notmuch-part from ;; the newline.) > + > (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)