* [PATCH] completion: Add support for custom header prefixes
@ 2024-01-16 18:07 Per Modin
0 siblings, 0 replies; only message in thread
From: Per Modin @ 2024-01-16 18:07 UTC (permalink / raw)
To: notmuch
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-16 19:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:07 [PATCH] completion: Add support for custom header prefixes Per Modin
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).