aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2021-08-24 08:17:38 -0700
committerDavid Bremner <david@tethera.net>2021-09-04 17:07:19 -0700
commit81b9dbd110593d6b1a370efb3576bf39585af2ea (patch)
tree0e151cf4e90d75f48bed905ff097a331569efee4
parent6ab2d9b1a2e62b76960df8e80ff2a45d9c6a8551 (diff)
CLI/config support saving s-expression queries
This commit does not enable using saved s-expression queries, only saving and retrieving them from the config file or the database. Use in queries will be enabled in a following commit.
-rw-r--r--doc/man1/notmuch-config.rst5
-rw-r--r--notmuch-config.c1
-rwxr-xr-xtest/T081-sexpr-search.sh13
3 files changed, 19 insertions, 0 deletions
diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
index 07a9eaf0..7d901758 100644
--- a/doc/man1/notmuch-config.rst
+++ b/doc/man1/notmuch-config.rst
@@ -251,6 +251,11 @@ paths are presumed relative to `$HOME` for items in section
:any:`notmuch-search-terms(7)` for more information about named
queries.
+**squery.<name>**
+ Expansion for named query called <name>, using s-expression syntax. See
+ :any:`notmuch-sexp-queries(7)` for more information about s-expression
+ queries.
+
FILES
=====
diff --git a/notmuch-config.c b/notmuch-config.c
index c0c91cc8..db00a26c 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -517,6 +517,7 @@ static const struct config_key
{ "index.decrypt", false, NULL },
{ "index.header.", true, validate_field_name },
{ "query.", true, NULL },
+ { "squery.", true, validate_field_name },
};
static const config_key_info_t *
diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh
index 22e53335..e0de0304 100755
--- a/test/T081-sexpr-search.sh
+++ b/test/T081-sexpr-search.sh
@@ -812,4 +812,17 @@ notmuch search 'List:"notmuch notmuchmail org"' | notmuch_search_sanitize > EXPE
notmuch search --query=sexp '(List notmuch notmuchmail org)' | notmuch_search_sanitize > OUTPUT
test_expect_equal_file EXPECTED OUTPUT
+test_begin_subtest "check saved query name"
+test_expect_code 1 "notmuch config set squery.test '(subject utf8-sübjéct)'"
+
+test_begin_subtest "roundtrip saved query (database)"
+notmuch config set --database squery.Test '(subject utf8-sübjéct)'
+output=$(notmuch config get squery.Test)
+test_expect_equal "$output" '(subject utf8-sübjéct)'
+
+test_begin_subtest "roundtrip saved query"
+notmuch config set squery.Test '(subject override subject)'
+output=$(notmuch config get squery.Test)
+test_expect_equal "$output" '(subject override subject)'
+
test_done