[PATCH] completion: load all addresses and cache in _email-notmuch

Subject: [PATCH] completion: load all addresses and cache in _email-notmuch

Date: Mon, 17 Sep 2018 23:08:52 +0200

To: notmuch@notmuchmail.org

Cc:

From: Vincent Breitmoser


---
 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..c6db00b6 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)"} )
 
-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

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: