From: David Bremner <david@tethera.net>
To: Ico <ico@pruts.nl>, notmuch@notmuchmail.org
Subject: [PATCH] WIP: provide relative lastmod sexp queries
Date: Mon, 8 Aug 2022 08:50:00 -0300 [thread overview]
Message-ID: <20220808115000.1559492-1-david@tethera.net> (raw)
In-Reply-To: <20161202140115.62194.22060@localhost.localdomain>
---
I haven't looked carefully at how much work it would be to add to the
infix parser yet. I suspect it means adding a new RangeProcessor class
modelled on ParseTimeRangeProcessor. Maybe some of the logic from
_parse_sexp_range could be shared with the other parser.
lib/parse-sexp.cc | 6 ++++++
test/T570-revision-tracking.sh | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc
index 0f14d8b7..e9ef4268 100644
--- a/lib/parse-sexp.cc
+++ b/lib/parse-sexp.cc
@@ -575,6 +575,9 @@ _sexp_parse_range (notmuch_database_t *notmuch, const _sexp_prefix_t *prefix,
return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
}
+ if (from_idx < 0)
+ from_idx += notmuch_database_get_revision (notmuch, NULL);
+
try {
if (EMPTY_STRING (to))
to_idx = LONG_MAX;
@@ -585,6 +588,9 @@ _sexp_parse_range (notmuch_database_t *notmuch, const _sexp_prefix_t *prefix,
return NOTMUCH_STATUS_BAD_QUERY_SYNTAX;
}
+ if (to_idx < 0)
+ to_idx += notmuch_database_get_revision (notmuch, NULL);
+
output = Xapian::Query (Xapian::Query::OP_VALUE_RANGE, NOTMUCH_VALUE_LAST_MOD,
Xapian::sortable_serialise (from_idx),
Xapian::sortable_serialise (to_idx));
diff --git a/test/T570-revision-tracking.sh b/test/T570-revision-tracking.sh
index e1cc684d..aaa45468 100755
--- a/test/T570-revision-tracking.sh
+++ b/test/T570-revision-tracking.sh
@@ -95,4 +95,12 @@ subtotal=$(notmuch count lastmod:..$lastmod)
result=$(($subtotal == $total-1))
test_expect_equal 1 "$result"
+if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
+ test_begin_subtest 'exclude one message using negative lastmod (sexp)'
+ total=$(notmuch count '*')
+ notmuch tag +${RANDOM} id:4EFC743A.3060609@april.org
+ count=$(notmuch count --query=sexp '(lastmod -1 *)')
+ test_expect_equal 1 "$count"
+fi
+
test_done
--
2.35.2
next prev parent reply other threads:[~2022-08-08 11:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 14:01 Feature request: search for last N modified mails Ico
2016-12-03 13:22 ` cesar mena
2022-08-08 11:50 ` David Bremner [this message]
2022-08-09 11:25 ` [PATCH 2/3] WIP/lib: factor out lastmod range handling from sexp parser David Bremner
2022-08-09 11:25 ` [PATCH 3/3] WIP/lib: use common lastmod logic in infix parser David Bremner
2022-09-03 11:51 ` Feature request: search for last N modified mails David Bremner
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=20220808115000.1559492-1-david@tethera.net \
--to=david@tethera.net \
--cc=ico@pruts.nl \
--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).