From: Per Modin <per@modin.io>
To: notmuch@notmuchmail.org
Subject: [PATCH] completion: Add support for custom header prefixes
Date: Tue, 16 Jan 2024 18:07:54 +0000 [thread overview]
Message-ID: <v5n4okgfmdt77ouj3p4i5ksaa7x63w5gixvjv6jyxmvxx4fxtl@j6vlxg3sey43> (raw)
Append custom search query prefixes, if any, to the standard set of
terms used for searching. Applies to both bash and zsh, and is checked
with Awk and GNU Awk.
---
completion/notmuch-completion.bash | 4 ++++
completion/zsh/_notmuch | 3 +++
2 files changed, 7 insertions(+)
diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash
index 3748846e..cb363719 100644
--- a/completion/notmuch-completion.bash
+++ b/completion/notmuch-completion.bash
@@ -123,6 +123,10 @@ _notmuch_search_terms()
;;
*)
local search_terms="from: to: subject: attachment: mimetype: tag: id: thread: folder: path: date: lastmod: query: property:"
+
+ # append custom search terms, if any
+ search_terms="${search_terms}$(notmuch config list | awk -F'[.=]' '/index\.header\./ { printf " %s:", $3 }')"
+
compopt -o nospace
COMPREPLY=( $(compgen -W "${search_terms}" -- ${cur}) )
;;
diff --git a/completion/zsh/_notmuch b/completion/zsh/_notmuch
index 0bdd7f77..d779ceb5 100644
--- a/completion/zsh/_notmuch
+++ b/completion/zsh/_notmuch
@@ -112,6 +112,9 @@ _notmuch_search_term() {
'from' 'to' 'subject' 'attachment' 'mimetype' 'tag' 'id' 'thread' 'path' 'folder' 'date' 'lastmod' 'query' 'property'
)
+ # append custom search terms, if any
+ notmuch_search_terms+=("${(@f)$(notmuch config list | awk -F'[.=]' '/index\.header\./ { print $3 }')}")
+
if compset -P '(#b)([^:]#):'; then
if (( $+functions[_notmuch_term_$match[1]] )); then
_notmuch_term_$match[1] && ret=0
--
2.43.0
reply other threads:[~2024-01-16 19:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=v5n4okgfmdt77ouj3p4i5ksaa7x63w5gixvjv6jyxmvxx4fxtl@j6vlxg3sey43 \
--to=per@modin.io \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).