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 3/5] emacs: show: add invisibility button action
Date: Sat, 15 Dec 2012 00:45:30 -0500	[thread overview]
Message-ID: <876243oolh.fsf@awakening.csail.mit.edu> (raw)
In-Reply-To: <1355389924-3718-4-git-send-email-markwalters1009@gmail.com>

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

  reply	other threads:[~2012-12-15  5:45 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
2012-12-13  9:12 ` [PATCH v2 3/5] emacs: show: add invisibility button action Mark Walters
2012-12-15  5:45   ` Austin Clements [this message]
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=876243oolh.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).