From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 671A96DE10A6 for ; Mon, 17 Sep 2018 14:13:17 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.012 X-Spam-Level: X-Spam-Status: No, score=-0.012 tagged_above=-999 required=5 tests=[AWL=0.098, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S1eNqO34CRhU for ; Mon, 17 Sep 2018 14:13:16 -0700 (PDT) Received: from mail.mugenguild.com (mugenguild.com [5.135.189.5]) by arlo.cworth.org (Postfix) with ESMTPS id BDF796DE10A5 for ; Mon, 17 Sep 2018 14:13:16 -0700 (PDT) Received: from localhost (i59F77CE8.versanet.de [89.247.124.232]) by mail.mugenguild.com (Postfix) with ESMTPSA id 4FACA5FA07; Mon, 17 Sep 2018 23:13:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=my.amazin.horse; s=mail; t=1537218795; bh=dTsayeb3swruyF5KwuslC1E/wwPV/T9VrZ6lV35Yua8=; h=From:To:Subject:Date:From; b=c4ztLWIP8G+FrtqFJmFISjNd1xZ0+bLrikQ9zKdFzYHs9QxA6ytfv/oYb2kSvZMQh Z6CW4ctmB4aso991dJPEZ/OZwoYKlHuGu4fLTEjLFPI20WJASZqKjqvB5vOSOdhFWY 9N5ecAbrRyWlkagiWcTg/HbYapdXxUVRrIbtVnZc= From: Vincent Breitmoser To: notmuch@notmuchmail.org Subject: [PATCH] completion: load all addresses and cache in _email-notmuch Date: Mon, 17 Sep 2018 23:12:36 +0200 Message-Id: <20180917211235.8571-2-look@my.amazin.horse> X-Mailer: git-send-email 2.18.0 In-Reply-To: <871s9si90d.fsf@tethera.net> References: <871s9si90d.fsf@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Sep 2018 21:13:17 -0000 This loads all known email addresses for completion, and caches the result. The cache validity is based on `notmuch count --lastmod mid:nonexistent`. --- completion/zsh/_email-notmuch | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/completion/zsh/_email-notmuch b/completion/zsh/_email-notmuch index 291c2358..89dfd414 100644 --- a/completion/zsh/_email-notmuch +++ b/completion/zsh/_email-notmuch @@ -2,8 +2,14 @@ local expl local -a notmuch_addr +local notmuch_addr_lastmod +local lastmod=( ${(f)"$(notmuch count --lastmod mid:nonexistent)"} ) -notmuch_addr=( ${(f)"$(notmuch address --deduplicate=address --output=address -- $PREFIX'*')"} ) +if ! _retrieve_cache notmuch-addresses || [[ $lastmod != $notmuch_addr_lastmod ]]; then + notmuch_addr_lastmod=$lastmod + notmuch_addr=( ${(f)"$(notmuch address --deduplicate=address --output=address -- '*')"} ) + _store_cache notmuch-addresses notmuch_addr notmuch_addr_lastmod +fi _description notmuch-addr expl 'email address (notmuch)' compadd "$expl[@]" -a notmuch_addr -- 2.18.0