[PATCH RFC] index: add body: search query term

2018-10-09 Thread William Casarin
This adds the ability to search specifically on the body

eg.

notmuch search tag:notmuch and body:PATCH

Signed-off-by: William Casarin 
---

Hey there,

I'm looking to add the ability to search specifically on the body. I
was poking around in the indexer, added these lines and reindexed a
few tags. It appears to work!

I was just wondering if there's anything I'm missing? That seemed a
bit too easy. I noticed there are some NOTMUCH_FIELDS that I'm not
sure what they do.

If anyone has any xapian knowledge that could shine some insight into
what the next steps might be, if any.

Thanks!
Will


 lib/database.cc | 3 +++
 lib/index.cc| 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/database.cc b/lib/database.cc
index 9cf8062c..0b085b21 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -297,6 +297,9 @@ prefix_t prefix_table[] = {
 { "subject",   "XSUBJECT", NOTMUCH_FIELD_EXTERNAL |
NOTMUCH_FIELD_PROBABILISTIC |
NOTMUCH_FIELD_PROCESSOR},
+{ "body",  "XBODY",NOTMUCH_FIELD_EXTERNAL |
+   NOTMUCH_FIELD_PROBABILISTIC |
+   NOTMUCH_FIELD_PROCESSOR},
 };
 
 static void
diff --git a/lib/index.cc b/lib/index.cc
index 3f694387..299b8770 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -506,7 +506,7 @@ _index_mime_part (notmuch_message_t *message,
 body = (char *) g_byte_array_free (byte_array, false);
 
 if (body) {
-   _notmuch_message_gen_terms (message, NULL, body);
+   _notmuch_message_gen_terms (message, "body", body);
 
free (body);
 }
-- 
2.19.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: tell me how to do this right (mail sent to lists)

2018-10-09 Thread Carl Worth
On Tue, Oct 09 2018, Jeff Templon wrote:
> So here’s the deal : I am tagging with afew, it has a special mailing
> list filter, which does the right thing - it tags the copy that was
> delivered from the mailing list with the list name.

I think you may be mistaken about the above details.

If the two messages have the same message ID, then as far as notmuch is
concerned that is just a single message, (that happens to be backed by
multiple files).

> However (and maybe this is just the Emacs interface?) when I view the
> message in notmuch-emacs, it only shows one of them, and this seems to
> be (always?  at least usually) the copy that is Fcc’d to my sent
> folder and tagged only with “sent” because it doesn’t have a list-id
> yet.

It is true that if a single message is backed by multiple files, the
notmuch-emacs interface will only display one of them. But even if you
changed which one it chooses (which would require some new code as far
as I know) shouldn't change what tags you are seeing.

> So I’m still looking for how to do this “right”.  I must not be the
> only one that sends mails to mailing lists?

You're certainly not the only one. Hopefully, what you really want
doesn't require the ability to maintain separate tags for these two
very-similar messages, (since notmuch cannot do that currently).

I guess the question I have is: What has given you the idea that afew is
tagging one message but not the other?

-Carl



signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: tell me how to do this right (mail sent to lists)

2018-10-09 Thread Jeff Templon

Hi Daniel,

Thanks for answering!

On 9 Oct 2018, at 18:08, Daniel Kahn Gillmor wrote:

notmuch doesn't "skip" anything -- it just knows that they are the 
same
e-mail due to message-id matching.  it actually indexes both texts.  
you

can see this with:

notmuch search --output=files id:$MESSAGEID



Indeed - with the command line tool in this form, I do see both files.  
Read

on :-)


I'd prefer to have both, but if I have to pick one or the other, I'd
actually prefer to have the second one, as I'd then have

[ pdp ]

as the start of the subject header for ALL mails to that list, and as 
an
added bonus, afew (should?) then tag them with the list name making 
them

easily searchable.


I'd recommend doing your tagging based on something other than a
substring of the subject line -- wouldn't tagging based on the 
recipient

of the message (To: or Cc:) be sufficient to group your mailing list
messages under one heading, regardless of which variant notmuch 
chooses

to prefer?


So here’s the deal : I am tagging with afew, it has a special mailing 
list filter,
which does the right thing - it tags the copy that was delivered from 
the mailing
list with the list name.  However (and maybe this is just the Emacs 
interface?) when
I view the message in notmuch-emacs, it only shows one of them, and this 
seems to be
(always?  at least usually) the copy that is Fcc’d to my sent folder 
and tagged only

with “sent” because it doesn’t have a list-id yet.

So I’m still looking for how to do this “right”.  I must not be 
the only one that sends

mails to mailing lists?

JT
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: tell me how to do this right (mail sent to lists)

2018-10-09 Thread Daniel Kahn Gillmor
Hi Jeff--

On Tue 2018-10-09 17:02:05 +0200, Jeff Templon wrote:
> I can see via another imap client (in this case MailMate / OS X) that
> there are two messages in imap, both with the same messageid.  One
> example right now (printing the Subject header below):
>
> in my sent mail folder:
>
> [Physics@Veldhoven] Inschrijving/Registration Physics@Veldhoven 2019 deadline 
> 9 November 2019
>
> and in my inbox:
>
> [pdp] [Physics@Veldhoven] Inschrijving/Registration Physics@Veldhoven 2019: 
> deadline 9 November 2019
>
> However, in notmuch-emacs, I only see the first one.  My guess is that
> notmuch has first seen the one in "sent", indexed that, and then seeing
> the second one with the same messageId, skips it.

notmuch doesn't "skip" anything -- it just knows that they are the same
e-mail due to message-id matching.  it actually indexes both texts.  you
can see this with:

notmuch search --output=files id:$MESSAGEID

> I'd prefer to have both, but if I have to pick one or the other, I'd
> actually prefer to have the second one, as I'd then have
>
> [ pdp ]
>
> as the start of the subject header for ALL mails to that list, and as an
> added bonus, afew (should?) then tag them with the list name making them
> easily searchable.

I'd recommend doing your tagging based on something other than a
substring of the subject line -- wouldn't tagging based on the recipient
of the message (To: or Cc:) be sufficient to group your mailing list
messages under one heading, regardless of which variant notmuch chooses
to prefer?

i recognize this doesn't answer your proximal question -- and i'd love
to hear if someone more knowledgable has a good answer for it.  i'm just
offering a workaround for what i think is your ultimate goal.

all the best,

 --dkg
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


tell me how to do this right (mail sent to lists)

2018-10-09 Thread Jeff Templon
Hi,

The use case: I send a message to a mailing list of which I am a member.

I can see via another imap client (in this case MailMate / OS X) that
there are two messages in imap, both with the same messageid.  One
example right now (printing the Subject header below):

in my sent mail folder:

[Physics@Veldhoven] Inschrijving/Registration Physics@Veldhoven 2019 deadline 9 
November 2019

and in my inbox:

[pdp] [Physics@Veldhoven] Inschrijving/Registration Physics@Veldhoven 2019: 
deadline 9 November 2019


However, in notmuch-emacs, I only see the first one.  My guess is that
notmuch has first seen the one in "sent", indexed that, and then seeing
the second one with the same messageId, skips it.  I'd prefer to have
both, but if I have to pick one or the other, I'd actually prefer to
have the second one, as I'd then have

[ pdp ]

as the start of the subject header for ALL mails to that list, and as an
added bonus, afew (should?) then tag them with the list name making them
easily searchable.

So how does one do this "right"?

Thanks,

JT
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch