From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/3] emacs/show: optionally insert bodies lazily
Date: Sun, 5 Jun 2022 14:08:50 -0300 [thread overview]
Message-ID: <20220605170851.1595387-3-david@tethera.net> (raw)
In-Reply-To: <20220605170851.1595387-1-david@tethera.net>
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
next prev parent reply other threads:[~2022-06-05 17:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-05 17:08 WIP/RFP: lazy body insertion for notmuch-show mode David Bremner
2022-06-05 17:08 ` [PATCH 1/3] perf-test/emacs: test showing a longish thread David Bremner
2022-06-05 17:08 ` David Bremner [this message]
2022-06-05 17:08 ` [PATCH 3/3] perf-test/emacs: lazily insert message bodies with notmuch-show David Bremner
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=20220605170851.1595387-3-david@tethera.net \
--to=david@tethera.net \
--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).