aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-06-26 09:04:27 -0300
committerDavid Bremner <david@tethera.net>2021-06-27 14:37:45 -0300
commit563b2a0032124c313fce0b52be2e62c75bc55d60 (patch)
tree18cf195e2642fdc462479f0c7f99153b95cbe26f
parent14326e6cb77fe3061dc7ea70419837c7c19c34ae (diff)
emacs/show: add parameter notmuch-show-single-message
This dynamically bound variable can be set when the caller of notmuch-show guarantees that exactly one message will match the query. It avoids transporting and parsing the complete thread structure.
-rw-r--r--emacs/notmuch-show.el11
1 files changed, 8 insertions, 3 deletions
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 939f8913..9a95eb34 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -179,6 +179,8 @@ indentation."
(defvar-local notmuch-show-indent-content t)
+(defvar-local notmuch-show-single-message nil)
+
(defvar notmuch-show-attachment-debug nil
"If t log stdout and stderr from attachment handlers.
@@ -1315,9 +1317,10 @@ Apply the previously saved STATE if supplied, otherwise show the
first relevant message.
If no messages match the query return NIL."
- (let* ((cli-args (cons "--exclude=false"
- (and notmuch-show-elide-non-matching-messages
- (list "--entire-thread=false"))))
+ (let* ((cli-args (list "--exclude=false"))
+ (cli-args (if notmuch-show-elide-non-matching-messages (cons "--entire-thread=false" cli-args) cli-args))
+ ;; "part 0 is the whole message (headers and body)" notmuch-show(1)
+ (cli-args (if notmuch-show-single-message (cons "--part=0" cli-args) cli-args))
(queries (notmuch-show--build-queries
notmuch-show-thread-id notmuch-show-query-context))
(forest nil)
@@ -1328,6 +1331,8 @@ If no messages match the query return NIL."
(while (and (not forest) queries)
(setq forest (notmuch-query-get-threads
(append cli-args (list "'") (car queries) (list "'"))))
+ (when (and forest notmuch-show-single-message)
+ (setq forest (list (list (list forest)))))
(setq queries (cdr queries)))
(when forest
(notmuch-show-insert-forest forest)