From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uAmhAesX12CPaQEAgWs5BA (envelope-from ) for ; Sat, 26 Jun 2021 14:04:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id eOL4OOoX12CJWwAA1q6Kng (envelope-from ) for ; Sat, 26 Jun 2021 12:04:58 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9155417EBF for ; Sat, 26 Jun 2021 14:04:58 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id EEFC2290D1; Sat, 26 Jun 2021 08:04:46 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 63DB7290A8 for ; Sat, 26 Jun 2021 08:04:41 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 5AA605FD21; Sat, 26 Jun 2021 08:04:41 -0400 (EDT) Received: (nullmailer pid 153678 invoked by uid 1000); Sat, 26 Jun 2021 12:04:37 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 2/3] emacs/show: add parameter notmuch-show-single-message Date: Sat, 26 Jun 2021 09:04:27 -0300 Message-Id: <20210626120428.153445-3-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210626120428.153445-1-david@tethera.net> References: <20210626120428.153445-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 5YD6RYWFKFP23LSAHE7RLZFHWWJFAEAQ X-Message-ID-Hash: 5YD6RYWFKFP23LSAHE7RLZFHWWJFAEAQ 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; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624709098; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc: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-unsubscribe:list-subscribe:list-post; bh=u+AXEgYunR9BAHVr3dAPTUEyr7kuBBMnZAHgtTuwz0A=; b=Gb4hv2HxXBeCIU7gNyNK7enP4KVjlBFKPUdjWR4UQbc6spls6TPCmKaJP1xIPabvLskj0t aMd3GGFHOjmumnMsk4NIXnOVPcQ7rvYMBeGpkbG1hQQT51la+oJbcL1OwiWYeFWLB/V02+ wpJNKZdJgDjdtYJqNEI8qrpb/mGhqlLN7vGXtXOxR12125uWXA/w3Cw3ogx22jmiKCLaBB uk2W46w+0/xIaSdfRsPo9wQxXTatKowqoyk/jPm+CAZvIpV4KgBfJvC0zeA/duF0nf8Ycb xCWj6Cdk0lBQylYn+pqRhJKUCv/Nb0CpaHlqyOnlRaSoUrcqRT6L6O7GpRO70A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624709098; a=rsa-sha256; cv=none; b=XWZX1cLGJfNPwsivxxOIhoPqcYM7OoEVluYzetNaa7RWCA9vmDdDbNvrwOdtjp41Tc91CG h5b9YoIziVZrnEHsvqygyV/3f21nN7R2Y5CHbZH1+gbSEZJlcOmABaj5SKSbADsEGKEEns Lk489rKIZVuq/jz7ROR7ChOkBxXB/n1P1pTxMmW8Unxqi9sx1RCmRiFeUP0NACvwtzLGq3 6NuuOHdhIL6AzvGczGokG8IJVsvAtUSYCYNIy26i1sbrubdvCXySfzItUdCueSVYR4W+8o oUYgTx4QKwhODNgZIxrydUo8d0oV3zL+q4y3OLyOBlDRgx9eHujNcW+21AjXsQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.06 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 9155417EBF X-Spam-Score: -1.06 X-Migadu-Scanner: scn1.migadu.com X-TUID: ulhJtaPTPgRz 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. --- emacs/notmuch-show.el | 11 ++++++++--- 1 file 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) -- 2.30.2