From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org,
Austin Clements <aclements@csail.mit.edu>,
Adam Wolfe Gordon <awg+notmuch@xvx.ca>
Subject: [PATCH v3 4/5] emacs: show: modify the way hidden state is recorded.
Date: Fri, 31 May 2013 19:26:45 +0100 [thread overview]
Message-ID: <1370024806-6616-5-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1370024806-6616-1-git-send-email-markwalters1009@gmail.com>
Previously, whether a part was hidden or shown was recorded in the
invisibility/visibility of the part overlay. Since we are going to
have lazily rendered parts with no overlay store the hidden/shown
state in the part button itself.
Additionally, in preparation for the invisible part handling move the
actual hiding of the hidden parts to insert-bodypart from
create-part-overlays.
Finally, we will need to know whether a part-insertion has done
anything (it won't if the invisible part cannot be displayed by emacs)
so we slightly rejig the code order in
notmuch-show-toggle-part-invisibility to make it easier for the
function to set an appropriate return value.
---
emacs/notmuch-show.el | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 66cc3a5..89199e8 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -495,6 +495,7 @@ message at DEPTH in the current thread."
(concat "[ " base-label " ]")
:base-label base-label
:type 'notmuch-show-part-button-type
+ :notmuch-part-hidden nil
:notmuch-part nth
:notmuch-filename name
:notmuch-content-type content-type))
@@ -555,18 +556,20 @@ message at DEPTH in the current thread."
(let* ((button (or button (button-at (point))))
(overlay (button-get button 'overlay)))
(when overlay
- (let* ((show (overlay-get overlay 'invisible))
+ (let* ((show (button-get button :notmuch-part-hidden))
(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))
+ ;; Toggle the button itself.
+ (button-put button :notmuch-part-hidden (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))))))))
+ (goto-char (min old-point (1- (button-end button))))
+ (overlay-put overlay 'invisible (not show))))))
(defun notmuch-show-multipart/*-to-list (part)
(mapcar (lambda (inner-part) (plist-get inner-part :content-type))
@@ -851,7 +854,7 @@ message at DEPTH in the current thread."
(setq handlers (cdr handlers))))
t)
-(defun notmuch-show-create-part-overlays (button beg end hide)
+(defun notmuch-show-create-part-overlays (button beg end)
"Add an overlay to the part between BEG and END"
;; If there is no button (i.e., the part is text/plain and the first
@@ -859,11 +862,9 @@ message at DEPTH in the current thread."
;; toggleable.
(when (and button (/= beg end))
(button-put button 'overlay (make-overlay 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)))))
+ ;; Return true if we created an overlay.
+ t))
+
(defun notmuch-show-insert-bodypart (msg part depth &optional hide)
"Insert the body part PART at depth DEPTH in the current thread.
@@ -889,7 +890,9 @@ 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 beg (point) hide)))
+ (notmuch-show-create-part-overlays button beg (point))
+ (when hide
+ (notmuch-show-toggle-part-invisibility button))))
(defun notmuch-show-insert-body (msg body depth)
"Insert the body BODY at depth DEPTH in the current thread."
--
1.7.10.4
next prev parent reply other threads:[~2013-05-31 18:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-31 18:26 [PATCH v3 0/5] emacs: show: lazy handling of hidden parts Mark Walters
2013-05-31 18:26 ` [PATCH v3 1/5] emacs: show: fake wash parts are handled at insert-bodypart level Mark Walters
2013-05-31 18:26 ` [PATCH v3 2/5] emacs: show: move the insertion of the header button to the top level Mark Walters
2013-05-31 18:26 ` [PATCH v3 3/5] emacs: show: pass button to create-overlays Mark Walters
2013-05-31 22:59 ` Austin Clements
2013-05-31 23:08 ` Mark Walters
2013-05-31 23:12 ` Austin Clements
2013-05-31 18:26 ` Mark Walters [this message]
2013-05-31 23:09 ` [PATCH v3 4/5] emacs: show: modify the way hidden state is recorded Austin Clements
2013-05-31 18:26 ` [PATCH v3 5/5] emacs: show: implement lazy hidden part handling Mark Walters
2013-05-31 23:33 ` [PATCH v3 0/5] emacs: show: lazy handling of hidden parts 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=1370024806-6616-5-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--cc=aclements@csail.mit.edu \
--cc=awg+notmuch@xvx.ca \
--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).