unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v5 0/6] emacs: show: lazy handling of hidden parts
@ 2013-06-10  4:57 Mark Walters
  2013-06-10  4:57 ` [PATCH v5 1/6] emacs: show: fake wash parts are handled at insert-bodypart level Mark Walters
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Mark Walters @ 2013-06-10  4:57 UTC (permalink / raw)
  To: notmuch, Austin Clements

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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-06-12 15:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-10  4:57 [PATCH v5 0/6] emacs: show: lazy handling of hidden parts Mark Walters
2013-06-10  4:57 ` [PATCH v5 1/6] emacs: show: fake wash parts are handled at insert-bodypart level Mark Walters
2013-06-10  4:57 ` [PATCH v5 2/6] emacs: show: move the insertion of the header button to the top level Mark Walters
2013-06-10  4:57 ` [PATCH v5 3/6] emacs: show: pass button to create-overlays Mark Walters
2013-06-10  4:57 ` [PATCH v5 4/6] emacs: show: modify the way hidden state is recorded Mark Walters
2013-06-10  4:57 ` [PATCH v5 5/6] emacs: show move addition of :notmuch-part to separate function Mark Walters
2013-06-10  4:57 ` [PATCH v5 6/6] emacs: show: implement lazy hidden part handling Mark Walters
2013-06-10  5:07 ` [PATCH v5 0/6] emacs: show: lazy handling of hidden parts Austin Clements
2013-06-10 15:22 ` Tomi Ollila
2013-06-10 15:57 ` Adam Wolfe Gordon
2013-06-12 15:12 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).