From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS49981 109.236.80.0/20 X-Spam-Status: No, score=-3.1 required=3.0 tests=AWL,BAYES_00,RDNS_NONE, SPF_FAIL,SPF_HELO_FAIL,TO_EQ_FM_DOM_SPF_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from 80x24.org (unknown [109.236.90.209]) by dcvr.yhbt.net (Postfix) with ESMTP id 429F61FA14 for ; Wed, 12 Apr 2017 20:17:50 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] wip Date: Wed, 12 Apr 2017 20:17:47 +0000 Message-Id: <20170412201747.27440-1-e@80x24.org> List-Id: --- lib/PublicInbox/Search.pm | 9 ++++++--- lib/PublicInbox/SearchIdx.pm | 15 ++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 02d1827..7005b6f 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -74,6 +74,9 @@ my %prob_prefix = ( q => 'XQUOT', nq => 'XNQ', + df => 'XDF', + da => 'XDA', + db => 'XDB', # default: '' => 'XMID S A XNQ XQUOT XFN', @@ -97,12 +100,12 @@ EOF 'a:' => 'match within the To, Cc, and From headers', 'tc:' => 'match within the To and Cc headers', 'bs:' => 'match within the Subject and body', + 'df:' => 'match filenames from diff', + 'da:' => 'diff pre-image removed (-) lines', + 'db:' => 'diff post-image added(+) lines', ); chomp @HELP; # TODO: -# df (filenames from diff) -# da (diff a/ removed lines) -# db (diff b/ added lines) my $mail_query = Search::Xapian::Query->new('T' . 'mail'); diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 8200b54..c8f5205 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -130,10 +130,15 @@ sub index_users ($$) { } sub index_body ($$$) { - my ($tg, $lines, $inc) = @_; - $tg->index_text(join("\n", @$lines), $inc, $inc ? 'XNQ' : 'XQUOT'); - @$lines = (); + my ($tg, $lines, $doc) = @_; + my $txt = join("\n", @$lines); + $tg->index_text($txt, !!$doc, $doc ? 'XNQ' : 'XQUOT'); $tg->increase_termpos; + if ($doc && $txt =~ /^[\-\+]/ms) { # does it look like a diff? + foreach (@$lines) { + } + } + @$lines = (); } sub add_message { @@ -200,7 +205,7 @@ sub add_message { my @lines = split(/\n/, $body); while (defined(my $l = shift @lines)) { if ($l =~ /^>/) { - index_body($tg, \@orig, 1) if @orig; + index_body($tg, \@orig, $doc) if @orig; push @quot, $l; } else { index_body($tg, \@quot, 0) if @quot; @@ -208,7 +213,7 @@ sub add_message { } } index_body($tg, \@quot, 0) if @quot; - index_body($tg, \@orig, 1) if @orig; + index_body($tg, \@orig, $doc) if @orig; }); link_message($self, $smsg, $old_tid); -- EW