unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <aclements@csail.mit.edu>
To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH v2 2/5] emacs: show: add overlays for each part
Date: Sat, 15 Dec 2012 00:39:58 -0500	[thread overview]
Message-ID: <878v8zooup.fsf@awakening.csail.mit.edu> (raw)
In-Reply-To: <1355389924-3718-3-git-send-email-markwalters1009@gmail.com>

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

  reply	other threads:[~2012-12-15  5:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878v8zooup.fsf@awakening.csail.mit.edu \
    --to=aclements@csail.mit.edu \
    --cc=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).