* [PATCH] emacs: show: hide large text attachments by default
@ 2015-03-28 11:08 Mark Walters
2015-03-28 14:35 ` David Bremner
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mark Walters @ 2015-03-28 11:08 UTC (permalink / raw)
To: notmuch
notmuch-show can be slow displaying large attachments so hide them by
default. The default maximum size is 10000 bytes/characters but it is
customizable.
Note that notmuch-show-insert-bodypart is also called from the reply
code so we need to be a little careful.
---
This code is getting a little fragile -- there are quite a lot of
factors in deciding whether to show or hide a part and the code is
called from both show and reply -- but it seems to work. For testing I
suggest setting notmuch-show-max-text-part-size to something small
like 100 or 1000.
Best wishes
Mark
emacs/notmuch-show.el | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f4ad802..2a53461 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -99,6 +99,13 @@ visible for any given message."
:group 'notmuch-show
:group 'notmuch-hooks)
+(defcustom notmuch-show-max-text-part-size 10000
+ "Maximum size of a text part to be shown by default in characters.
+
+Set to 0 to show the part regardless of size."
+ :type 'integer
+ :group 'notmuch-show)
+
;; Mostly useful for debugging.
(defcustom notmuch-show-all-multipart/alternative-parts nil
"Should all parts of multipart/alternative parts be shown?"
@@ -937,14 +944,20 @@ useful for quoting in replies)."
"text/x-diff")
content-type))
(nth (plist-get part :id))
+ (long (and (notmuch-match-content-type mime-type "text/*")
+ (> notmuch-show-max-text-part-size 0)
+ (> (length (plist-get part :content)) notmuch-show-max-text-part-size)))
(beg (point))
- ;; Hide the part initially if HIDE is t.
- (show-part (not (equal hide t)))
;; We omit the part button for the first (or only) part if
;; this is text/plain, or HIDE is 'no-buttons.
(button (unless (or (equal hide 'no-buttons)
(and (string= mime-type "text/plain") (<= nth 1)))
(notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))
+ ;; Hide the part initially if HIDE is t, or if it is too long
+ ;; and we have a button to allow toggling (thus reply which
+ ;; uses 'no-buttons automatically includes long parts)
+ (show-part (not (or (equal hide t)
+ (and long button))))
(content-beg (point)))
;; Store the computed mime-type for later use (e.g. by attachment handlers).
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] emacs: show: hide large text attachments by default
2015-03-28 11:08 [PATCH] emacs: show: hide large text attachments by default Mark Walters
@ 2015-03-28 14:35 ` David Bremner
2015-04-01 6:59 ` David Bremner
2015-04-03 23:15 ` David Bremner
2 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2015-03-28 14:35 UTC (permalink / raw)
To: Mark Walters, notmuch
Mark Walters <markwalters1009@gmail.com> writes:
> notmuch-show can be slow displaying large attachments so hide them by
> default. The default maximum size is 10000 bytes/characters but it is
> customizable.
>
> Note that notmuch-show-insert-bodypart is also called from the reply
> code so we need to be a little careful.
I didn't look at the code yet, but I can confirm it makes a huge (about
17 times faster) difference for the problematic thread I have been
profiling.
d
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] emacs: show: hide large text attachments by default
2015-03-28 11:08 [PATCH] emacs: show: hide large text attachments by default Mark Walters
2015-03-28 14:35 ` David Bremner
@ 2015-04-01 6:59 ` David Bremner
2015-04-03 23:15 ` David Bremner
2 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2015-04-01 6:59 UTC (permalink / raw)
To: Mark Walters, notmuch
Mark Walters <markwalters1009@gmail.com> writes:
>
> This code is getting a little fragile -- there are quite a lot of
> factors in deciding whether to show or hide a part and the code is
> called from both show and reply -- but it seems to work. For testing I
> suggest setting notmuch-show-max-text-part-size to something small
> like 100 or 1000.
The change looks ok, and as I mentioned it in a previous mail, it seems
to work well, at least for the notmuch-show bottleneck I know how to
test.
d
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] emacs: show: hide large text attachments by default
2015-03-28 11:08 [PATCH] emacs: show: hide large text attachments by default Mark Walters
2015-03-28 14:35 ` David Bremner
2015-04-01 6:59 ` David Bremner
@ 2015-04-03 23:15 ` David Bremner
2 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2015-04-03 23:15 UTC (permalink / raw)
To: Mark Walters, notmuch
Mark Walters <markwalters1009@gmail.com> writes:
> notmuch-show can be slow displaying large attachments so hide them by
> default. The default maximum size is 10000 bytes/characters but it is
> customizable.
>
> Note that notmuch-show-insert-bodypart is also called from the reply
> code so we need to be a little careful.
pushed,
d
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-03 23:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-28 11:08 [PATCH] emacs: show: hide large text attachments by default Mark Walters
2015-03-28 14:35 ` David Bremner
2015-04-01 6:59 ` David Bremner
2015-04-03 23:15 ` David Bremner
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).