Intially control lazy insertion by a depth limit. --- emacs/notmuch-show.el | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 203ca7f0..55c4e274 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -111,6 +111,12 @@ displayed." (function :tag "Function")) :group 'notmuch-show) +(defcustom notmuch-show-depth-limit nil + "Depth beyond which message bodies are inserted lazily" + :type '(choice (const :tag "No limit" nil) + (number :tag "Limit" 10)) + :group 'notmuch-show) + (defcustom notmuch-show-relative-dates t "Display relative dates in the message summary line." :type 'boolean @@ -1065,13 +1071,35 @@ is t, hide the part initially and show the button." (notmuch-show-toggle-part-invisibility button))) (notmuch-show-record-part-information part beg (point)))) +(defun notmuch-show--insert-body-internal (msg body depth) + (mapc (lambda (part) (notmuch-show-insert-bodypart msg part depth)) body)) + +(defun notmuch-show--insert-body-button (msg body depth) + (insert-button + "[body]" + :type 'notmuch-button-type + 'action (lambda (button) + (save-excursion + (let* ((inhibit-read-only t) + (start (button-start button)) + (end (button-end button)) + (marker (copy-marker (1+ end)))) + (delete-region start end) + (notmuch-show--insert-body-internal msg body depth) + (when notmuch-show-indent-content + (indent-rigidly start marker + (* notmuch-show-indent-messages-width depth)))))))) + (defun notmuch-show-insert-body (msg body depth) "Insert the body BODY at depth DEPTH in the current thread." ;; Register all content IDs for this message. According to RFC ;; 2392, content IDs are *global*, but it's okay if an MUA treats ;; them as only global within a message. (notmuch-show--register-cids msg (car body)) - (mapc (lambda (part) (notmuch-show-insert-bodypart msg part depth)) body)) + (if (and notmuch-show-depth-limit + (> depth notmuch-show-depth-limit)) + (notmuch-show--insert-body-button msg body depth) + (notmuch-show--insert-body-internal msg body depth))) (defun notmuch-show-make-symbol (type) (make-symbol (concat "notmuch-show-" type))) -- 2.35.2 _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org