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

This is version 2 of the patch series (version 1 at
id:1354663662-20524-1-git-send-email-markwalters1009@gmail.com)

Almost all of the changes and fixes are in response to Austin's
review. I have changed things as he suggested.

There are two small extra tiny patches in this version: I set the
default value of notmuch-show-all-multipart/alternative-parts to nil.

The second is to fix a bug reported by Jani: that fake-patch parts (as
provided by notmuch-wash) did not get hidden when the whole message
was hidden.  This was due to notmuch-wash-convert-inline-patch-to-part
not passing a msg on down to notmuch-show-insert-bodypart. Previously
this did not matter but with with this series msg is needed to
construct the correct overlays.

Best wishes

Mark




Mark Walters (5):
  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: wash: fix fake-diff part to include msg parameter
  emacs: show: set default show-all-multipart/alternatives to nil

 emacs/notmuch-show.el |  115 ++++++++++++++++++++++++++++++++++++++-----------
 emacs/notmuch-wash.el |    2 +-
 2 files changed, 90 insertions(+), 27 deletions(-)

-- 
1.7.9.1

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

* [PATCH v2 1/5] emacs: show: modify insert-part-header to save the button text
  2012-12-13  9:11 [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Mark Walters
@ 2012-12-13  9:12 ` Mark Walters
  2012-12-13  9:12 ` [PATCH v2 2/5] emacs: show: add overlays for each part Mark Walters
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: Mark Walters @ 2012-12-13  9:12 UTC (permalink / raw)
  To: notmuch

This just make notmuch-show-insert-part-header save the basic button
text for parts as an attribute. This makes it simpler for the button
action (added in a later patch) to reword the label as appropriate (eg
append "(not shown)" or not as appropriate).
---
 emacs/notmuch-show.el |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index d7fa10e..06f7ca5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -483,17 +483,17 @@ message at DEPTH in the current thread."
 (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)
 
 (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment)
-  (let ((button))
+  (let ((button)
+	(base-label (concat (when name (concat name ": "))
+			    declared-type
+			    (unless (string-equal declared-type content-type)
+			      (concat " (as " content-type ")"))
+			    comment)))
+
     (setq button
 	  (insert-button
-	   (concat "[ "
-		   (if name (concat name ": ") "")
-		   declared-type
-		   (if (not (string-equal declared-type content-type))
-		       (concat " (as " content-type ")")
-		     "")
-		   (or comment "")
-		   " ]")
+	   (concat "[ " base-label " ]")
+	   :base-label base-label
 	   :type 'notmuch-show-part-button-type
 	   :notmuch-part nth
 	   :notmuch-filename name
-- 
1.7.9.1

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

* [PATCH v2 2/5] emacs: show: add overlays for each part
  2012-12-13  9:11 [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Mark Walters
  2012-12-13  9:12 ` [PATCH v2 1/5] emacs: show: modify insert-part-header to save the button text Mark Walters
@ 2012-12-13  9:12 ` Mark Walters
  2012-12-15  5:39   ` Austin Clements
  2012-12-13  9:12 ` [PATCH v2 3/5] emacs: show: add invisibility button action Mark Walters
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Mark Walters @ 2012-12-13  9:12 UTC (permalink / raw)
  To: notmuch

This makes notmuch-show-insert-bodypart add an overlay for any
non-trivial part with a button header (currently the first text/plain
part does not have a button). At this point the overlay is available
to the button but there is no action using it yet.

In addition the argument HIDE is passed down to
notmuch-show-insert-part-overlays to request that the part be hidden
by default but this is not acted on yet.
---
 emacs/notmuch-show.el |   61 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 06f7ca5..3f2f277 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -567,11 +567,10 @@ message at DEPTH in the current thread."
     ;; but it's not clear that this is the wrong thing to do - which
     ;; should be chosen if there are more than one that match?
     (mapc (lambda (inner-part)
-	    (let ((inner-type (plist-get inner-part :content-type)))
-	      (if (or notmuch-show-all-multipart/alternative-parts
-		      (string= chosen-type inner-type))
-		  (notmuch-show-insert-bodypart msg inner-part depth)
-		(notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
+	    (let* ((inner-type (plist-get inner-part :content-type))
+		  (hide (not (or notmuch-show-all-multipart/alternative-parts
+			   (string= chosen-type inner-type)))))
+	      (notmuch-show-insert-bodypart msg inner-part depth hide)))
 	  inner-parts)
 
     (when notmuch-show-indent-multipart
@@ -839,17 +838,49 @@ message at DEPTH in the current thread."
       (setq handlers (cdr handlers))))
   t)
 
-(defun notmuch-show-insert-bodypart (msg part depth)
-  "Insert the body part PART at depth DEPTH in the current thread."
+(defun notmuch-show-insert-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.
+    (when (and button (/= part-beg end))
+      (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)
+	(overlay-put overlay 'type "part")
+	;; 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)))))
+
+(defun notmuch-show-insert-bodypart (msg part depth &optional hide)
+  "Insert the body part PART at depth DEPTH in the current thread.
+
+If HIDE is non-nil then initially hide this part."
   (let ((content-type (downcase (plist-get part :content-type)))
-	(nth (plist-get part :id)))
-    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
-  ;; Some of the body part handlers leave point somewhere up in the
-  ;; part, so we make sure that we're down at the end.
-  (goto-char (point-max))
-  ;; Ensure that the part ends with a carriage return.
-  (unless (bolp)
-    (insert "\n")))
+	(nth (plist-get part :id))
+	(beg (point)))
+
+    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
+    ;; Some of the body part handlers leave point somewhere up in the
+    ;; part, so we make sure that we're down at the end.
+    (goto-char (point-max))
+    ;; Ensure that the part ends with a carriage return.
+    (unless (bolp)
+      (insert "\n"))
+    (notmuch-show-insert-part-overlays msg beg (point) hide)))
 
 (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] 9+ messages in thread

* [PATCH v2 3/5] emacs: show: add invisibility button action
  2012-12-13  9:11 [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Mark Walters
  2012-12-13  9:12 ` [PATCH v2 1/5] emacs: show: modify insert-part-header to save the button text Mark Walters
  2012-12-13  9:12 ` [PATCH v2 2/5] emacs: show: add overlays for each part Mark Walters
@ 2012-12-13  9:12 ` Mark Walters
  2012-12-15  5:45   ` Austin Clements
  2012-12-13  9:12 ` [PATCH v2 4/5] emacs: wash: fix fake-diff part to include msg parameter Mark Walters
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 9+ messages in thread
From: Mark Walters @ 2012-12-13  9:12 UTC (permalink / raw)
  To: notmuch

This adds a button action to show hidden parts. In this version "t"
toggles the visibility of a part. In addition "RET" on a non-shown
part shows it.

The button is used to hide parts when appropriate (eg text/html in
multipart/alternative).
---
 emacs/notmuch-show.el |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 3f2f277..202258f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -478,6 +478,7 @@ message at DEPTH in the current thread."
     (define-key map "v" 'notmuch-show-part-button-view)
     (define-key map "o" 'notmuch-show-part-button-interactively-view)
     (define-key map "|" 'notmuch-show-part-button-pipe)
+    (define-key map "t" 'notmuch-show-toggle-invisible-part-action)
     map)
   "Submap for button commands")
 (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)
@@ -554,6 +555,28 @@ message at DEPTH in the current thread."
     (let ((handle (mm-make-handle (current-buffer) (list content-type))))
       (mm-pipe-part handle))))
 
+;; This is taken from notmuch-wash: maybe it should be unified?
+(defun notmuch-show-toggle-invisible-part-action (&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)))
+    (when overlay
+      (if show
+	  (remove-from-invisibility-spec invis-spec)
+	(add-to-invisibility-spec invis-spec))
+      (let* ((new-start (button-start button))
+	     (button-label (button-get button :base-label))
+	     (old-point (point))
+	     (inhibit-read-only t))
+	(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))))))))
+
 (defun notmuch-show-multipart/*-to-list (part)
   (mapcar (lambda (inner-part) (plist-get inner-part :content-type))
 	  (plist-get part :content)))
@@ -863,7 +886,13 @@ message at DEPTH in the current thread."
 			       (cons invis-spec (overlay-get inner 'invisible)))))
 
 	(button-put button 'invisibility-spec invis-spec)
-	(button-put button 'overlay overlay)))))
+	(button-put button 'overlay overlay))
+
+      ;; We toggle the button for hidden parts as that gets the
+      ;; button label right.
+      (save-excursion
+	(when hide
+	  (notmuch-show-toggle-invisible-part-action button))))))
 
 (defun notmuch-show-insert-bodypart (msg part depth &optional hide)
   "Insert the body part PART at depth DEPTH in the current thread.
@@ -1992,7 +2021,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."
 
 (defun notmuch-show-part-button-default (&optional button)
   (interactive)
-  (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))
+  (let ((button (or button (button-at (point)))))
+    (if (button-get button 'invisibility-spec)
+	(notmuch-show-toggle-invisible-part-action button)
+      (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))))
 
 (defun notmuch-show-part-button-save (&optional button)
   (interactive)
-- 
1.7.9.1

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

* [PATCH v2 4/5] emacs: wash: fix fake-diff part to include msg parameter
  2012-12-13  9:11 [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Mark Walters
                   ` (2 preceding siblings ...)
  2012-12-13  9:12 ` [PATCH v2 3/5] emacs: show: add invisibility button action Mark Walters
@ 2012-12-13  9:12 ` Mark Walters
  2012-12-13  9:12 ` [PATCH v2 5/5] emacs: show: set default show-all-multipart/alternatives to nil Mark Walters
  2012-12-15  5:52 ` [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Austin Clements
  5 siblings, 0 replies; 9+ messages in thread
From: Mark Walters @ 2012-12-13  9:12 UTC (permalink / raw)
  To: notmuch

The fake-diff part from notmuch wash did not pass the msg parameter to
notmuch-show-insert-bodypart. Previously this did not matter, but is
now needed to get the overlays right for invisibility.
---
 emacs/notmuch-wash.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 7d003a2..b2affba 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -378,7 +378,7 @@ for error."
 			       (plist-get
 				(plist-get msg :headers) :Subject))))
 	(delete-region (point-min) (point-max))
-	(notmuch-show-insert-bodypart nil part depth)))))
+	(notmuch-show-insert-bodypart msg part depth)))))
 
 ;;
 
-- 
1.7.9.1

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

* [PATCH v2 5/5] emacs: show: set default show-all-multipart/alternatives to nil
  2012-12-13  9:11 [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Mark Walters
                   ` (3 preceding siblings ...)
  2012-12-13  9:12 ` [PATCH v2 4/5] emacs: wash: fix fake-diff part to include msg parameter Mark Walters
@ 2012-12-13  9:12 ` Mark Walters
  2012-12-15  5:52 ` [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Austin Clements
  5 siblings, 0 replies; 9+ messages in thread
From: Mark Walters @ 2012-12-13  9:12 UTC (permalink / raw)
  To: notmuch

Now that the invisibility display of parts is present we no longer
need to force the display of all multipart/alternatives: users can
toggle them for themselves when needed.
---
 emacs/notmuch-show.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 202258f..c43dd32 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -94,7 +94,7 @@ visible for any given message."
   :group 'notmuch-hooks)
 
 ;; Mostly useful for debugging.
-(defcustom notmuch-show-all-multipart/alternative-parts t
+(defcustom notmuch-show-all-multipart/alternative-parts nil
   "Should all parts of multipart/alternative parts be shown?"
   :type 'boolean
   :group 'notmuch-show)
-- 
1.7.9.1

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

* Re: [PATCH v2 2/5] emacs: show: add overlays for each part
  2012-12-13  9:12 ` [PATCH v2 2/5] emacs: show: add overlays for each part Mark Walters
@ 2012-12-15  5:39   ` Austin Clements
  0 siblings, 0 replies; 9+ messages in thread
From: Austin Clements @ 2012-12-15  5:39 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Thu, 13 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> This makes notmuch-show-insert-bodypart add an overlay for any
> non-trivial part with a button header (currently the first text/plain
> part does not have a button). At this point the overlay is available
> to the button but there is no action using it yet.
>
> In addition the argument HIDE is passed down to
> notmuch-show-insert-part-overlays to request that the part be hidden
> by default but this is not acted on yet.
> ---
>  emacs/notmuch-show.el |   61 +++++++++++++++++++++++++++++++++++++------------
>  1 files changed, 46 insertions(+), 15 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 06f7ca5..3f2f277 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -567,11 +567,10 @@ message at DEPTH in the current thread."
>      ;; but it's not clear that this is the wrong thing to do - which
>      ;; should be chosen if there are more than one that match?
>      (mapc (lambda (inner-part)
> -	    (let ((inner-type (plist-get inner-part :content-type)))
> -	      (if (or notmuch-show-all-multipart/alternative-parts
> -		      (string= chosen-type inner-type))
> -		  (notmuch-show-insert-bodypart msg inner-part depth)
> -		(notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
> +	    (let* ((inner-type (plist-get inner-part :content-type))
> +		  (hide (not (or notmuch-show-all-multipart/alternative-parts
> +			   (string= chosen-type inner-type)))))
> +	      (notmuch-show-insert-bodypart msg inner-part depth hide)))
>  	  inner-parts)
>  
>      (when notmuch-show-indent-multipart
> @@ -839,17 +838,49 @@ message at DEPTH in the current thread."
>        (setq handlers (cdr handlers))))
>    t)
>  
> -(defun notmuch-show-insert-bodypart (msg part depth)
> -  "Insert the body part PART at depth DEPTH in the current thread."
> +(defun notmuch-show-insert-part-overlays (msg beg end hide)

notmuch-show-create-part-overlays?  The other show-insert functions
actually insert text into the buffer.

> +  "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.
> +    (when (and button (/= part-beg end))
> +      (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)
> +	(overlay-put overlay 'type "part")

Since you're not actually using notmuch-wash, you don't need this 'type
property.

> +	;; 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)))))
> +
> +(defun notmuch-show-insert-bodypart (msg part depth &optional hide)
> +  "Insert the body part PART at depth DEPTH in the current thread.
> +
> +If HIDE is non-nil then initially hide this part."
>    (let ((content-type (downcase (plist-get part :content-type)))
> -	(nth (plist-get part :id)))
> -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
> -  ;; Some of the body part handlers leave point somewhere up in the
> -  ;; part, so we make sure that we're down at the end.
> -  (goto-char (point-max))
> -  ;; Ensure that the part ends with a carriage return.
> -  (unless (bolp)
> -    (insert "\n")))
> +	(nth (plist-get part :id))
> +	(beg (point)))
> +
> +    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)
> +    ;; Some of the body part handlers leave point somewhere up in the
> +    ;; part, so we make sure that we're down at the end.
> +    (goto-char (point-max))
> +    ;; Ensure that the part ends with a carriage return.
> +    (unless (bolp)
> +      (insert "\n"))
> +    (notmuch-show-insert-part-overlays msg beg (point) hide)))
>  
>  (defun notmuch-show-insert-body (msg body depth)
>    "Insert the body BODY at depth DEPTH in the current thread."
> -- 
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH v2 3/5] emacs: show: add invisibility button action
  2012-12-13  9:12 ` [PATCH v2 3/5] emacs: show: add invisibility button action Mark Walters
@ 2012-12-15  5:45   ` Austin Clements
  0 siblings, 0 replies; 9+ messages in thread
From: Austin Clements @ 2012-12-15  5:45 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Thu, 13 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> This adds a button action to show hidden parts. In this version "t"
> toggles the visibility of a part. In addition "RET" on a non-shown
> part shows it.
>
> The button is used to hide parts when appropriate (eg text/html in
> multipart/alternative).
> ---
>  emacs/notmuch-show.el |   36 ++++++++++++++++++++++++++++++++++--
>  1 files changed, 34 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 3f2f277..202258f 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -478,6 +478,7 @@ message at DEPTH in the current thread."
>      (define-key map "v" 'notmuch-show-part-button-view)
>      (define-key map "o" 'notmuch-show-part-button-interactively-view)
>      (define-key map "|" 'notmuch-show-part-button-pipe)
> +    (define-key map "t" 'notmuch-show-toggle-invisible-part-action)

Do we actually need this?  Isn't it redundant with RET in all cases
where t would be meaningful?

>      map)
>    "Submap for button commands")
>  (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)
> @@ -554,6 +555,28 @@ message at DEPTH in the current thread."
>      (let ((handle (mm-make-handle (current-buffer) (list content-type))))
>        (mm-pipe-part handle))))
>  
> +;; This is taken from notmuch-wash: maybe it should be unified?
> +(defun notmuch-show-toggle-invisible-part-action (&optional button)

notmuch-show-toggle-part-invisibility?

> +  (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)))
> +    (when overlay
> +      (if show
> +	  (remove-from-invisibility-spec invis-spec)
> +	(add-to-invisibility-spec invis-spec))
> +      (let* ((new-start (button-start button))
> +	     (button-label (button-get button :base-label))
> +	     (old-point (point))
> +	     (inhibit-read-only t))
> +	(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))))))))
> +
>  (defun notmuch-show-multipart/*-to-list (part)
>    (mapcar (lambda (inner-part) (plist-get inner-part :content-type))
>  	  (plist-get part :content)))
> @@ -863,7 +886,13 @@ message at DEPTH in the current thread."
>  			       (cons invis-spec (overlay-get inner 'invisible)))))
>  
>  	(button-put button 'invisibility-spec invis-spec)
> -	(button-put button 'overlay overlay)))))
> +	(button-put button 'overlay overlay))
> +
> +      ;; We toggle the button for hidden parts as that gets the
> +      ;; button label right.
> +      (save-excursion
> +	(when hide
> +	  (notmuch-show-toggle-invisible-part-action button))))))
>  
>  (defun notmuch-show-insert-bodypart (msg part depth &optional hide)
>    "Insert the body part PART at depth DEPTH in the current thread.
> @@ -1992,7 +2021,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."
>  
>  (defun notmuch-show-part-button-default (&optional button)
>    (interactive)
> -  (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))
> +  (let ((button (or button (button-at (point)))))
> +    (if (button-get button 'invisibility-spec)
> +	(notmuch-show-toggle-invisible-part-action button)
> +      (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))))
>  
>  (defun notmuch-show-part-button-save (&optional button)
>    (interactive)
> -- 
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart
  2012-12-13  9:11 [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Mark Walters
                   ` (4 preceding siblings ...)
  2012-12-13  9:12 ` [PATCH v2 5/5] emacs: show: set default show-all-multipart/alternatives to nil Mark Walters
@ 2012-12-15  5:52 ` Austin Clements
  5 siblings, 0 replies; 9+ messages in thread
From: Austin Clements @ 2012-12-15  5:52 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Thu, 13 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> This is version 2 of the patch series (version 1 at
> id:1354663662-20524-1-git-send-email-markwalters1009@gmail.com)
>
> Almost all of the changes and fixes are in response to Austin's
> review. I have changed things as he suggested.
>
> There are two small extra tiny patches in this version: I set the
> default value of notmuch-show-all-multipart/alternative-parts to nil.
>
> The second is to fix a bug reported by Jani: that fake-patch parts (as
> provided by notmuch-wash) did not get hidden when the whole message
> was hidden.  This was due to notmuch-wash-convert-inline-patch-to-part
> not passing a msg on down to notmuch-show-insert-bodypart. Previously
> this did not matter but with with this series msg is needed to
> construct the correct overlays.
>
> Best wishes
>
> Mark

This series LGTM other than the few little things I pointed out.

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

end of thread, other threads:[~2012-12-15  5:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13  9:11 [PATCH v2 0/5] Use invisibility to toggle display of all parts including multipart Mark Walters
2012-12-13  9:12 ` [PATCH v2 1/5] emacs: show: modify insert-part-header to save the button text Mark Walters
2012-12-13  9:12 ` [PATCH v2 2/5] emacs: show: add overlays for each part Mark Walters
2012-12-15  5:39   ` Austin Clements
2012-12-13  9:12 ` [PATCH v2 3/5] emacs: show: add invisibility button action Mark Walters
2012-12-15  5:45   ` Austin Clements
2012-12-13  9:12 ` [PATCH v2 4/5] emacs: wash: fix fake-diff part to include msg parameter Mark Walters
2012-12-13  9:12 ` [PATCH v2 5/5] emacs: show: set default show-all-multipart/alternatives to nil Mark Walters
2012-12-15  5:52 ` [PATCH v2 0/5] 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).