From b42e2026aaf21e487009cfe574d40c2096d32f29 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Mon, 10 Jun 2013 05:57:07 +0100 Subject: [PATCH] [PATCH v5 0/6] emacs: show: lazy handling of hidden parts --- f5/b8cbdbb38bfc84c2114fd7b8766b6ac9402c48 | 177 ++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 f5/b8cbdbb38bfc84c2114fd7b8766b6ac9402c48 diff --git a/f5/b8cbdbb38bfc84c2114fd7b8766b6ac9402c48 b/f5/b8cbdbb38bfc84c2114fd7b8766b6ac9402c48 new file mode 100644 index 000000000..1def2f412 --- /dev/null +++ b/f5/b8cbdbb38bfc84c2114fd7b8766b6ac9402c48 @@ -0,0 +1,177 @@ +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 C67E1431FBF + for ; Sun, 9 Jun 2013 21:57:27 -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 6pMkc19OWKhP for ; + Sun, 9 Jun 2013 21:57:20 -0700 (PDT) +Received: from mail-ea0-f170.google.com (mail-ea0-f170.google.com + [209.85.215.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 15652431FAE + for ; Sun, 9 Jun 2013 21:57:19 -0700 (PDT) +Received: by mail-ea0-f170.google.com with SMTP id h10so5014610eaj.15 + for ; Sun, 09 Jun 2013 21:57:17 -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:x-mailer; + bh=nebVvu2+QLVdCUIZaU3L9DDfnxzPhjgM8j00rvMrUQE=; + b=Gf4HFEBJm6aMRRGxAMdGs4tCOURmsYZYGcPs38mnO4U6nG9NeJm2y7rU2ZJpm0F16y + vRho0//E89IKdoti8TZE3nmZgME0jStxNe0U9kXSDoulF8QJ/UfoJMGtOgx88sLPXtdZ + xHVKqVPPvej3jguBi6QtgiVuqNq6Zx9NJA6HgrSrODi70JOnPVJHkc6A640YCXaMHBcI + OHJVsz3TG97kVvWJmGYO54xZy184KX95JJPlBPDRMRSB/MGfehvyLE4akzxYqx003No2 + jJZ7fDQCl/WP1JsuU3atMEPw0lM4aB3hLqTIwfV1jGWuN7Pt4EhIkP3X9qrqyzNPO4hw + aWuA== +X-Received: by 10.15.48.129 with SMTP id h1mr8962712eew.65.1370840237502; + Sun, 09 Jun 2013 21:57:17 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id 3sm20257273een.7.2013.06.09.21.57.16 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 09 Jun 2013 21:57:16 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org, + Austin Clements +Subject: [PATCH v5 0/6] emacs: show: lazy handling of hidden parts +Date: Mon, 10 Jun 2013 05:57:07 +0100 +Message-Id: <1370840233-23258-1-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +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: Mon, 10 Jun 2013 04:57:28 -0000 + +This is version 5 of this patch set. Version 4 is at +id:1370074547-24677-1-git-send-email-markwalters1009@gmail.com. + +This version fixes the two bugs pointed out in Austin's review +id:20130610023952.GC22196@mit.edu. + +I decided to add the :notmuch-part text property separately from +create-overlays as they have slightly different regions (one includes +the button one does not) and are applied at slightly different times +(we do not create overlays for lazy parts). + +I was not sure whether we created two overlays for hidden lazy parts +in v4 (it might not have done as the part was empty and we do not +create overlays for empty parts) but that is stupidly fragile. Thus we +explicitly do not create overlays for lazy parts until they are +inserted. + +The diff from v4 is below. + +Best wishes + +Mark + + +Mark Walters (6): + emacs: show: fake wash parts are handled at insert-bodypart level + emacs: show: move the insertion of the header button to the top level + emacs: show: pass button to create-overlays + emacs: show: modify the way hidden state is recorded. + emacs: show move addition of :notmuch-part to separate function + emacs: show: implement lazy hidden part handling + + emacs/notmuch-show.el | 241 ++++++++++++++++++++++++++++++------------------- + 1 files changed, 146 insertions(+), 95 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index b963859..d030ea3 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -817,6 +817,27 @@ message at DEPTH in the current thread." + ;; Return true if we created an overlay. + t)) + ++(defun notmuch-show-record-part-information (part beg end) ++ "Store PART as a text property from BEG to END" ++ ++ ;; Record part information. Since we already inserted subparts, ++ ;; don't override existing :notmuch-part properties. ++ (notmuch-map-text-property beg end :notmuch-part ++ (lambda (v) (or v part))) ++ ;; Make :notmuch-part front sticky and rear non-sticky so it stays ++ ;; applied to the beginning of each line when we indent the ++ ;; message. Since we're operating on arbitrary renderer output, ++ ;; watch out for sticky specs of t, which means all properties are ++ ;; front-sticky/rear-nonsticky. ++ (notmuch-map-text-property beg end 'front-sticky ++ (lambda (v) (if (listp v) ++ (pushnew :notmuch-part v) ++ v))) ++ (notmuch-map-text-property beg end 'rear-nonsticky ++ (lambda (v) (if (listp v) ++ (pushnew :notmuch-part v) ++ v)))) ++ + (defun notmuch-show-lazy-part (part-args button) + ;; Insert the lazy part after the button for the part. We would just + ;; move to the start of the new line following the button and insert +@@ -843,6 +864,9 @@ message at DEPTH in the current thread." + (indent-rigidly part-beg part-end depth)) + (goto-char part-end) + (delete-char 1) ++ (notmuch-show-record-part-information (second part-args) ++ (button-start button) ++ part-end) + ;; Create the overlay. If the lazy-part turned out to be empty/not + ;; showable this returns nil. + (notmuch-show-create-part-overlays button part-beg part-end)))) +@@ -876,27 +900,13 @@ If HIDE is non-nil then initially hide this part." + ;; Ensure that the part ends with a carriage return. + (unless (bolp) + (insert "\n")) +- (notmuch-show-create-part-overlays button content-beg (point)) +- (when hide ++ ;; We do not create the overlay for hidden (lazy) parts until ++ ;; they are inserted. ++ (if (not hide) ++ (notmuch-show-create-part-overlays button content-beg (point)) + (save-excursion + (notmuch-show-toggle-part-invisibility button))) +- ;; Record part information. Since we already inserted subparts, +- ;; don't override existing :notmuch-part properties. +- (notmuch-map-text-property beg (point) :notmuch-part +- (lambda (v) (or v part))) +- ;; Make :notmuch-part front sticky and rear non-sticky so it stays +- ;; applied to the beginning of each line when we indent the +- ;; message. Since we're operating on arbitrary renderer output, +- ;; watch out for sticky specs of t, which means all properties are +- ;; front-sticky/rear-nonsticky. +- (notmuch-map-text-property beg (point) 'front-sticky +- (lambda (v) (if (listp v) +- (pushnew :notmuch-part v) +- v))) +- (notmuch-map-text-property beg (point) 'rear-nonsticky +- (lambda (v) (if (listp v) +- (pushnew :notmuch-part v) +- v))))) ++ (notmuch-show-record-part-information part beg (point)))) + + (defun notmuch-show-insert-body (msg body depth) + "Insert the body BODY at depth DEPTH in the current thread." + + +-- +1.7.9.1 + -- 2.26.2