From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MDAmBruysWI5ZwEAbAwnHQ (envelope-from ) for ; Tue, 21 Jun 2022 13:59:55 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id mJwfBruysWIwpwAA9RJhRA (envelope-from ) for ; Tue, 21 Jun 2022 13:59:55 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C37F3B2BE for ; Tue, 21 Jun 2022 13:59:54 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 479345F42C; Tue, 21 Jun 2022 11:59:45 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 810605E228 for ; Tue, 21 Jun 2022 11:59:41 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id BC4895FC01; Tue, 21 Jun 2022 07:59:40 -0400 (EDT) Received: (nullmailer pid 407977 invoked by uid 1000); Tue, 21 Jun 2022 11:59:38 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [RFC PATCH v2 2/2] emacs/show: optionally insert bodies lazily Date: Tue, 21 Jun 2022 08:59:33 -0300 Message-Id: <20220621115933.407563-3-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220621115933.407563-1-david@tethera.net> References: <20220621115933.407563-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: U74FUQRSGR3ZSQKXSM4HFLIFXKGZB5PD X-Message-ID-Hash: U74FUQRSGR3ZSQKXSM4HFLIFXKGZB5PD X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655812794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=cl+yHm5w1rfbzqv02XB+uBuMC0E4CzNvkH+ItsDQrlk=; b=kp/1xN/9sFHLFN2FqTmCa0jOL9wexB3YBc8SVnbq2IZoNtE2obTUBr+Xt7xvpFTTcs37kj aeHFR+Ozpwjg9SVaqM0EqlhmOcuNoY0XDjO0/zi1SLfGdfFYMr1j04JR9VzvjGm3h4Odup gm6Pzq9IpKaCFw+oAhX+H4XPscs5tgis+/AI/FZUtNzbNpo4CzM//xG75VtyTWkGYPrBv6 n/AtZA1wWa/rMuuzAh7YxNBE6BB3NLRTuDLLWHWGXpTqK7qZTroFqtQDIisVSbh/R/ubrX 6qdBqBv14FS+ruasJ4DibqFQzwDTqxvqCWcgSe3kGI4bysR7P3EuDHq+S/kz/g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655812794; a=rsa-sha256; cv=none; b=aqYyp/xPnNlVXm29xkq5Vyl9xPx2nRFHwxE2LRTciQa/O7hChgQoz05BvXBYk5s6v8OH0z gOhqxEf2vnfnz7Wc7peGqZAfUuwssKv4ZTE0AG2xPtbq23LVxAjbeM66epT1BWoUnyCLj+ gwqjC/faA+LQRJYLIhkXIQUG0jE5xfxykz+Mw9iJc3M/JGrra/LtP9bxuICEW3/6KpPh/t 9Q0eS8vh/xFsDimTU1JyK/ZpsZEvOMv+4IijT4gNALEfnwnqkvMQX+Q4Mic4JWiOlapMtS A2kWmURculqgcD7IeZR/oTm6oo6SyliWRxqrPIjx8YSk+NKiYZUjaQTESiX92w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.70 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: C37F3B2BE X-Spam-Score: -1.70 X-Migadu-Scanner: scn0.migadu.com X-TUID: dss5BDNd7TaU This leverages the machinery already there to insert buttons for attachments. --- doc/notmuch-emacs.rst | 3 + emacs/notmuch-show.el | 23 +++- test/T450-emacs-show.sh | 18 +++ .../notmuch-show-depth | 44 +++++++ .../notmuch-show-depth-1 | 119 ++++++++++++++++++ 5 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 test/emacs-show.expected-output/notmuch-show-depth create mode 100644 test/emacs-show.expected-output/notmuch-show-depth-1 diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst index 970cd7b7..c2d16c5f 100644 --- a/doc/notmuch-emacs.rst +++ b/doc/notmuch-emacs.rst @@ -277,6 +277,9 @@ Display of messages can be controlled by the following variables :index:`notmuch-show-header-line` |docstring::notmuch-show-header-line| +:index:`notmuch-show-depth-limit` + |docstring::notmuch-show-depth-limit| + :index:`notmuch-multipart/alternative-discouraged` Which mime types to hide by default for multipart messages. diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index aded1ee7..8a50fd54 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -111,6 +111,19 @@ displayed." (function :tag "Function")) :group 'notmuch-show) +(defcustom notmuch-show-depth-limit nil + "Depth beyond which message bodies are inserted lazily. + +If bound to an integer, any message with tree depth greater than +this insert will have its body inserted lazily, initially +inserting only a button to do the actual insertion. + +If this variable is set to nil (the default) no such lazy +insertion is done." + :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 @@ -1031,18 +1044,22 @@ is t, hide the part initially and show the button." (> notmuch-show-max-text-part-size 0) (> (length (plist-get part :content)) notmuch-show-max-text-part-size))) + (deep (and notmuch-show-depth-limit + (> depth notmuch-show-depth-limit))) (beg (point)) ;; This default header-p function omits the part button for ;; the first (or only) part if this is text/plain. - (button (and (funcall notmuch-show-insert-header-p-function part hide) + (button (and (or deep + (funcall notmuch-show-insert-header-p-function part hide)) (notmuch-show-insert-part-header nth mime-type (and content-type (downcase content-type)) (plist-get part :filename)))) - ;; Hide the part initially if HIDE is t, or if it is too long + ;; Hide the part initially if HIDE is t, or if it is too long/deep ;; and we have a button to allow toggling. (show-part (not (or (equal hide t) - (and long button)))) + (and long button) + (and deep button)))) (content-beg (point))) ;; Store the computed mime-type for later use (e.g. by attachment handlers). (plist-put part :computed-type mime-type) diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 0c1f6204..da9851b3 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -91,6 +91,24 @@ test_emacs '(let ((notmuch-show-only-matching-messages t)) (test-visible-output))' test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT +test_begin_subtest "Hide bodies of messages" +test_emacs '(let ((notmuch-show-depth-limit -1)) + (notmuch-search "thread:{id:87ocn0qh6d.fsf@yoom.home.cworth.org}") + (notmuch-test-wait) + (notmuch-search-show-thread) + (notmuch-test-wait) + (test-visible-output))' +test_expect_equal_file $EXPECTED/notmuch-show-depth OUTPUT + +test_begin_subtest "Hide bodies of messages (depth > 1)" +test_emacs '(let ((notmuch-show-depth-limit 1)) + (notmuch-search "thread:{id:87ocn0qh6d.fsf@yoom.home.cworth.org}") + (notmuch-test-wait) + (notmuch-search-show-thread) + (notmuch-test-wait) + (test-visible-output))' +test_expect_equal_file $EXPECTED/notmuch-show-depth-1 OUTPUT + test_begin_subtest "notmuch-show: elide non-matching messages (w/ notmuch-show-toggle-elide-non-matching)" test_emacs '(let ((notmuch-show-only-matching-messages nil)) (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"") diff --git a/test/emacs-show.expected-output/notmuch-show-depth b/test/emacs-show.expected-output/notmuch-show-depth new file mode 100644 index 00000000..8299519c --- /dev/null +++ b/test/emacs-show.expected-output/notmuch-show-depth @@ -0,0 +1,44 @@ +Lars Kellogg-Stedman (2009-11-17) (inbox signed) +Subject: [notmuch] Working with Maildir storage? +To: notmuch@notmuchmail.org +Date: Tue, 17 Nov 2009 14:00:54 -0500 + +[ multipart/mixed (hidden) ] + Mikhail Gusarov (2009-11-17) (inbox signed unread) + Subject: Re: [notmuch] Working with Maildir storage? + To: notmuch@notmuchmail.org + Date: Wed, 18 Nov 2009 01:02:38 +0600 + + [ multipart/mixed (hidden) ] + Lars Kellogg-Stedman (2009-11-17) (inbox signed) + Subject: Re: [notmuch] Working with Maildir storage? + To: Mikhail Gusarov + Cc: notmuch@notmuchmail.org + Date: Tue, 17 Nov 2009 15:33:01 -0500 + + [ multipart/mixed (hidden) ] + Mikhail Gusarov (2009-11-17) (inbox unread) + Subject: [notmuch] Working with Maildir storage? + To: notmuch@notmuchmail.org + Date: Wed, 18 Nov 2009 02:50:48 +0600 + + [ text/plain (hidden) ] + Keith Packard (2009-11-17) (inbox unread) + Subject: [notmuch] Working with Maildir storage? + To: notmuch@notmuchmail.org + Date: Tue, 17 Nov 2009 13:24:13 -0800 + + [ text/plain (hidden) ] + Lars Kellogg-Stedman (2009-11-18) (inbox signed unread) + Subject: Re: [notmuch] Working with Maildir storage? + To: Keith Packard + Cc: notmuch@notmuchmail.org + Date: Tue, 17 Nov 2009 19:50:40 -0500 + + [ multipart/mixed (hidden) ] + Carl Worth (2009-11-18) (inbox unread) + Subject: [notmuch] Working with Maildir storage? + To: notmuch@notmuchmail.org + Date: Wed, 18 Nov 2009 02:08:10 -0800 + + [ text/plain (hidden) ] diff --git a/test/emacs-show.expected-output/notmuch-show-depth-1 b/test/emacs-show.expected-output/notmuch-show-depth-1 new file mode 100644 index 00000000..e7c376bb --- /dev/null +++ b/test/emacs-show.expected-output/notmuch-show-depth-1 @@ -0,0 +1,119 @@ +Lars Kellogg-Stedman (2009-11-17) (inbox signed) +Subject: [notmuch] Working with Maildir storage? +To: notmuch@notmuchmail.org +Date: Tue, 17 Nov 2009 14:00:54 -0500 + +[ multipart/mixed ] +[ multipart/signed ] +[ Unknown key ID 0xD74695063141ACD8 or unsupported algorithm ] +[ text/plain ] +I saw the LWN article and decided to take a look at notmuch. I'm +currently using mutt and mairix to index and read a collection of +Maildir mail folders (around 40,000 messages total). + +notmuch indexed the messages without complaint, but my attempt at +searching bombed out. Running, for example: + + notmuch search storage + +Resulted in 4604 lines of errors along the lines of: + + Error opening + /home/lars/Mail/read-messages.2008/cur/1246413773.24928_27334.hostname,U=3026:2,S: + Too many open files + +I'm curious if this is expected behavior (i.e., notmuch does not work +with Maildir) or if something else is going on. + +Cheers, + +[ 4-line signature. Click/Enter to show. ] +[ application/pgp-signature ] +[ text/plain ] +[ 4-line signature. Click/Enter to show. ] + Mikhail Gusarov (2009-11-17) (inbox signed unread) + Subject: Re: [notmuch] Working with Maildir storage? + To: notmuch@notmuchmail.org + Date: Wed, 18 Nov 2009 01:02:38 +0600 + + [ multipart/mixed ] + [ multipart/signed ] + [ Unknown key ID 0x9D20F6503E338888 or unsupported algorithm ] + [ text/plain ] + + Twas brillig at 14:00:54 17.11.2009 UTC-05 when lars@seas.harvard.edu did + gyre and gimble: + + LK> Resulted in 4604 lines of errors along the lines of: + + LK> Error opening + LK> + /home/lars/Mail/read-messages.2008/cur/1246413773.24928_27334.hostname,U=3026:2,S: + LK> Too many open files + + See the patch just posted here. + + [ 2-line signature. Click/Enter to show. ] + [ application/pgp-signature ] + [ text/plain ] + [ 4-line signature. Click/Enter to show. ] + Lars Kellogg-Stedman (2009-11-17) (inbox signed) + Subject: Re: [notmuch] Working with Maildir storage? + To: Mikhail Gusarov + Cc: notmuch@notmuchmail.org + Date: Tue, 17 Nov 2009 15:33:01 -0500 + + [ multipart/mixed (hidden) ] + Mikhail Gusarov (2009-11-17) (inbox unread) + Subject: [notmuch] Working with Maildir storage? + To: notmuch@notmuchmail.org + Date: Wed, 18 Nov 2009 02:50:48 +0600 + + [ text/plain (hidden) ] + Keith Packard (2009-11-17) (inbox unread) + Subject: [notmuch] Working with Maildir storage? + To: notmuch@notmuchmail.org + Date: Tue, 17 Nov 2009 13:24:13 -0800 + + [ text/plain (hidden) ] + Lars Kellogg-Stedman (2009-11-18) (inbox signed unread) + Subject: Re: [notmuch] Working with Maildir storage? + To: Keith Packard + Cc: notmuch@notmuchmail.org + Date: Tue, 17 Nov 2009 19:50:40 -0500 + + [ multipart/mixed (hidden) ] + Carl Worth (2009-11-18) (inbox unread) + Subject: [notmuch] Working with Maildir storage? + To: notmuch@notmuchmail.org + Date: Wed, 18 Nov 2009 02:08:10 -0800 + + On Tue, 17 Nov 2009 14:00:54 -0500, Lars Kellogg-Stedman wrote: + > I saw the LWN article and decided to take a look at notmuch. I'm + > currently using mutt and mairix to index and read a collection of + > Maildir mail folders (around 40,000 messages total). + + Welcome, Lars! + + I hadn't even seen that Keith's blog post had been picked up by lwn.net. + That's very interesting. So, thanks for coming and trying out notmuch. + + > Error opening + > /home/lars/Mail/read-messages.2008/cur/1246413773.24928_27334.hostname,U=3026:2,S: + > Too many open files + + Sadly, the lwn article coincided with me having just introduced this + bug, and then getting on a Trans-Atlantic flight. So I fixed the bug + fairly quickly, but there was quite a bit of latency before I could push + the fix out. It should be fixed now. + + > I'm curious if this is expected behavior (i.e., notmuch does not work + > with Maildir) or if something else is going on. + + Notmuch works just fine with maildir---it's one of the things that it + likes the best. + + Happy hacking, + + -Carl -- 2.35.2