unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v5 0/4] Use invisibility to toggle display of all parts including multipart
@ 2012-12-18 19:27 Mark Walters
  2012-12-18 19:27 ` [PATCH v5 1/4] emacs: show: modify insert-part-header to save the button text Mark Walters
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Mark Walters @ 2012-12-18 19:27 UTC (permalink / raw)
  To: notmuch

This is an alternative version of
id:1355781287-6010-1-git-send-email-markwalters1009@gmail.com based on
top of Austin's patch at
id:1355812810-32747-1-git-send-email-amdragon@mit.edu

Austin's patch significantly simplifies the invisibility handling
taking this series down from 90/27 to 68/26 in diffstat terms.

In general terms Austin's approach has to be the right thing to do:
what we want to do just before the freeze is less clear. My view is
that we should go with Austin's approach now so that at least any bugs
we get from it and (more likely) from this series apply to master as
well. 

I am posting this series to make it easier for people to judge the two
approaches when finished (ie with part invisibility too).

I attach a trimmed diff from v4 below the diffstat (note this was a
diff with -U10 which I have trimmed so it is purely for information)

Note we no longer need patch 4/5 because in this approach the overlays
do not need to know about other overlays.

Best wishes

Mark






Mark Walters (4):
  emacs: show: modify insert-part-header to save the button text
  emacs: show: add overlays for each part
  emacs: show: add invisibility button action
  emacs: show: set default show-all-multipart/alternatives to nil

 emacs/notmuch-show.el |   94 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 68 insertions(+), 26 deletions(-)


Diff from v4

 emacs/notmuch-show.el |   33 ++++++---------------------------
 emacs/notmuch-wash.el |    2 +-
 2 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ee67fec..5751d98 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -551,31 +551,28 @@ message at DEPTH in the current thread."
 
 ;; This is taken from notmuch-wash: maybe it should be unified?
 (defun notmuch-show-toggle-part-invisibility (&optional button)
   (interactive)
   (let* ((button (or button (button-at (point))))
-	 (overlay (button-get button 'overlay))
-	 (invis-spec (button-get button 'invisibility-spec))
-	 (show (invisible-p invis-spec)))
+	 (overlay (button-get button 'overlay)))
     (when overlay
-      (if show
-	  (remove-from-invisibility-spec invis-spec)
-	(add-to-invisibility-spec invis-spec))
-      (let* ((new-start (button-start button))
+      (let* ((show (overlay-get overlay 'invisible))
+	     (new-start (button-start button))
 	     (button-label (button-get button :base-label))
 	     (old-point (point))
 	     (inhibit-read-only t))
+	(overlay-put overlay 'invisible (not show))
 	(goto-char new-start)
 	(insert "[ " button-label (if show " ]" " (hidden) ]"))
 	(let ((old-end (button-end button)))
 	  (move-overlay button new-start (point))
 	  (delete-region (point) old-end))
 	(goto-char (min old-point (1- (button-end button))))))))

@@ -862,39 +859,21 @@ message at DEPTH in the current thread."
 
 (defun notmuch-show-create-part-overlays (msg beg end hide)
   "Add an overlay to the part between BEG and END"
   (let* ((button (button-at beg))
 	 (part-beg (and button (1+ (button-end button)))))
 
     ;; If the part contains no text we do not make it toggleable. We
     ;; also need to check that the button is a genuine part button not
     ;; a notmuch-wash button.
     (when (and button (/= part-beg end) (button-get button :base-label))
-      (let ((base-label (button-get button :base-label))
-	    (overlay (make-overlay part-beg end))
-	    (message-invis-spec (plist-get msg :message-invis-spec))
-	    (invis-spec (make-symbol "notmuch-part-region")))
-
-	(overlay-put overlay 'invisible (list invis-spec message-invis-spec))
-	(overlay-put overlay 'priority 10)
-	;; Now we have to add invis-spec to every overlay this
-	;; overlay contains, otherwise these inner overlays will
-	;; override this one.
-	(dolist (inner (overlays-in part-beg end))
-	  (when (and (>= (overlay-start inner) part-beg)
-			   (<= (overlay-end inner) end))
-		  (overlay-put inner 'invisible
-			       (cons invis-spec (overlay-get inner 'invisible)))))
-
-	(button-put button 'invisibility-spec invis-spec)
-	(button-put button 'overlay overlay))
-
+      (button-put button 'overlay (make-overlay part-beg end))
       ;; We toggle the button for hidden parts as that gets the
       ;; button label right.
       (save-excursion
 	(when hide
 	  (notmuch-show-toggle-part-invisibility button))))))

@@ -1992,21 +1971,21 @@ If optional argument MLA is non-nil, use the provided key instead of prompting
 (defun notmuch-show-part-button-default (&optional button)
   (interactive)
   (let ((button (or button (button-at (point)))))
-    (if (button-get button 'invisibility-spec)
+    (if (button-get button 'overlay)
 	(notmuch-show-toggle-part-invisibility button)
       (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))))

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index e10ab66..d6db4fa 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -365,15 +365,15 @@ for error."
       (save-restriction
 	(narrow-to-region patch-start patch-end)
 	(setq part (plist-put part :content-type "inline-patch-fake-part"))
 	(setq part (plist-put part :content (buffer-string)))
 	(setq part (plist-put part :id -1))
 	(setq part (plist-put part :filename
 			      (notmuch-wash-subject-to-patch-filename
 			       (plist-get
 				(plist-get msg :headers) :Subject))))
 	(delete-region (point-min) (point-max))
-	(notmuch-show-insert-bodypart msg part depth)))))
+	(notmuch-show-insert-bodypart nil part depth)))))
 
 ;;
 
 (provide 'notmuch-wash)

-- 
1.7.9.1

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

end of thread, other threads:[~2012-12-21 14:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-18 19:27 [PATCH v5 0/4] Use invisibility to toggle display of all parts including multipart Mark Walters
2012-12-18 19:27 ` [PATCH v5 1/4] emacs: show: modify insert-part-header to save the button text Mark Walters
2012-12-21 14:10   ` David Bremner
2012-12-18 19:27 ` [PATCH v5 2/4] emacs: show: add overlays for each part Mark Walters
2012-12-18 19:27 ` [PATCH v5 3/4] emacs: show: add invisibility button action Mark Walters
2012-12-18 19:28 ` [PATCH v5 4/4] emacs: show: set default show-all-multipart/alternatives to nil Mark Walters
2012-12-19  5:11 ` [PATCH v5 0/4] Use invisibility to toggle display of all parts including multipart Austin Clements

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).