Commit notifications for all Sup repositories
 help / color / mirror / Atom feed
From: Dan Callaghan <dan@bl2.djc.id.au>
To: sup-commits@supmua.dev
Subject: [sup.git] 01/06: prepend type:mail to every search before parsing
Date: Sun, 18 Oct 2026 12:52:23 +1100	[thread overview]
Message-ID: <20261018015222.EF5ED29C46E@bl2.djc.id.au> (raw)
In-Reply-To: <179228834279.389402.1183876010618010579@bl2.djc.id.au>

New commit on branch develop:
https://supmua.dev/git/sup/commit/bcf87a864c5543ee5daf459fd9466b5d92b57da4.html

commit bcf87a864c5543ee5daf459fd9466b5d92b57da4
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sun Oct 11 16:25:12 2026 +1100

    prepend type:mail to every search before parsing
    
    The type:mail term matches everything in the index. This works around
    Xapian's QueryParser refusing to parse a query containing only negated
    terms.
    
    Fixes #250.
---
 lib/sup/index.rb        |  4 ++++
 test/unit/test_index.rb | 30 +++++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index 70afc8d7..82f28657 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -406,11 +406,15 @@ EOS
     query = {}
 
     subs = HookManager.run("custom-search", :subs => s) || s
+
+    subs = "type:mail #{subs}"
+
     begin
       subs = SearchManager.expand subs
     rescue SearchManager::ExpansionError => e
       raise ParseError, e.message
     end
+
     subs = subs.gsub(/\b(to|from):(\S+)\b/) do
       field, value = $1, $2
       email_field, name_field = %w(email name).map { |x| "#{field}_#{x}" }
diff --git a/test/unit/test_index.rb b/test/unit/test_index.rb
index 3f2bc213..08221aa2 100644
--- a/test/unit/test_index.rb
+++ b/test/unit/test_index.rb
@@ -32,34 +32,58 @@ class TestIndex < Minitest::Test
     parsed = with_fake_time do
       Redwood::Index.parse_query "after:yesterday"
     end
-    expected_qobj = Xapian::Query.new(
+    expected_date_qobj = Xapian::Query.new(
       Xapian::Query::OP_VALUE_RANGE,
       Redwood::Index::DATE_VALUENO,
       Xapian.sortable_serialise(Time.utc(2000, 1, 1).to_i),
       Xapian.sortable_serialise(2**32),
     )
+    expected_qobj = Xapian::Query.new(
+      0.0,
+      Xapian::Query.new(
+        Xapian::Query::OP_AND,
+        expected_date_qobj,
+        Xapian::Query.new("Kmail"),
+      ),
+    )
     assert_equal expected_qobj.description, parsed[:qobj].description
 
     parsed = with_fake_time do
       Redwood::Index.parse_query "before:yesterday"
     end
-    expected_qobj = Xapian::Query.new(
+    expected_date_qobj = Xapian::Query.new(
       Xapian::Query::OP_VALUE_RANGE,
       Redwood::Index::DATE_VALUENO,
       Xapian.sortable_serialise(0),
       Xapian.sortable_serialise(Time.utc(2000, 1, 1).to_i),
     )
+    expected_qobj = Xapian::Query.new(
+      0.0,
+      Xapian::Query.new(
+        Xapian::Query::OP_AND,
+        expected_date_qobj,
+        Xapian::Query.new("Kmail"),
+      ),
+    )
     assert_equal expected_qobj.description, parsed[:qobj].description
 
     parsed = with_fake_time do
       Redwood::Index.parse_query "during:yesterday"
     end
-    expected_qobj = Xapian::Query.new(
+    expected_date_qobj = Xapian::Query.new(
       Xapian::Query::OP_VALUE_RANGE,
       Redwood::Index::DATE_VALUENO,
       Xapian.sortable_serialise(Time.utc(1999, 12, 31).to_i),
       Xapian.sortable_serialise(Time.utc(2000,  1,  1).to_i),
     )
+    expected_qobj = Xapian::Query.new(
+      0.0,
+      Xapian::Query.new(
+        Xapian::Query::OP_AND,
+        expected_date_qobj,
+        Xapian::Query.new("Kmail"),
+      ),
+    )
     assert_equal expected_qobj.description, parsed[:qobj].description
   end
 end

  reply	other threads:[~2026-10-18  1:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-18  1:52 [sup.git] branch develop updated (cf3a2e38 -> c9f29b8d) Dan Callaghan
2026-10-18  1:52 ` Dan Callaghan [this message]
2026-10-18  1:52 ` [sup.git] 02/06: always set MIME-Version header on outgoing mails Dan Callaghan
2026-10-18  1:52 ` [sup.git] 03/06: unfold headers before further parsing Dan Callaghan
2026-10-18  1:52 ` [sup.git] 04/06: delete unused load_header method Dan Callaghan
2026-10-18  1:52 ` [sup.git] 05/06: move Source.parse_raw_email_header to EditMessageMode Dan Callaghan
2026-10-18  1:52 ` [sup.git] 06/06: ncursesw: 1.4.13 → 1.4.14 Dan Callaghan

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261018015222.EF5ED29C46E@bl2.djc.id.au \
    --to=dan@bl2.djc.id.au \
    --cc=djc@djc.id.au \
    --cc=sup-commits@supmua.dev \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox