mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
emacs: show: add overlays for each part
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.
This commit is contained in:
parent
fff2ea2ba9
commit
0c3a63f1af
1 changed files with 30 additions and 15 deletions
|
@ -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
|
;; 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?
|
;; should be chosen if there are more than one that match?
|
||||||
(mapc (lambda (inner-part)
|
(mapc (lambda (inner-part)
|
||||||
(let ((inner-type (plist-get inner-part :content-type)))
|
(let* ((inner-type (plist-get inner-part :content-type))
|
||||||
(if (or notmuch-show-all-multipart/alternative-parts
|
(hide (not (or notmuch-show-all-multipart/alternative-parts
|
||||||
(string= chosen-type inner-type))
|
(string= chosen-type inner-type)))))
|
||||||
(notmuch-show-insert-bodypart msg inner-part depth)
|
(notmuch-show-insert-bodypart msg inner-part depth hide)))
|
||||||
(notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))
|
|
||||||
inner-parts)
|
inner-parts)
|
||||||
|
|
||||||
(when notmuch-show-indent-multipart
|
(when notmuch-show-indent-multipart
|
||||||
|
@ -839,17 +838,33 @@ message at DEPTH in the current thread."
|
||||||
(setq handlers (cdr handlers))))
|
(setq handlers (cdr handlers))))
|
||||||
t)
|
t)
|
||||||
|
|
||||||
(defun notmuch-show-insert-bodypart (msg part depth)
|
(defun notmuch-show-create-part-overlays (msg beg end hide)
|
||||||
"Insert the body part PART at depth DEPTH in the current thread."
|
"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))
|
||||||
|
(button-put button 'overlay (make-overlay part-beg end)))))
|
||||||
|
|
||||||
|
(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)))
|
(let ((content-type (downcase (plist-get part :content-type)))
|
||||||
(nth (plist-get part :id)))
|
(nth (plist-get part :id))
|
||||||
(notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))
|
(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
|
;; Some of the body part handlers leave point somewhere up in the
|
||||||
;; part, so we make sure that we're down at the end.
|
;; part, so we make sure that we're down at the end.
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
;; Ensure that the part ends with a carriage return.
|
;; Ensure that the part ends with a carriage return.
|
||||||
(unless (bolp)
|
(unless (bolp)
|
||||||
(insert "\n")))
|
(insert "\n"))
|
||||||
|
(notmuch-show-create-part-overlays msg beg (point) hide)))
|
||||||
|
|
||||||
(defun notmuch-show-insert-body (msg body depth)
|
(defun notmuch-show-insert-body (msg body depth)
|
||||||
"Insert the body BODY at depth DEPTH in the current thread."
|
"Insert the body BODY at depth DEPTH in the current thread."
|
||||||
|
|
Loading…
Reference in a new issue