Re: searching for a message by path

Subject: Re: searching for a message by path

Date: Sat, 21 Sep 2024 17:01:58 +0800

To: frederik@ofb.net

Cc: notmuch@notmuchmail.org

From: Pengji Zhang


Frederick Eaton <frederik@ofb.net> writes:

> No, I already have that configuration. The first sentence 
> described what I already know how to do, the second sentence is 
> what I'm trying to do. 
> 
> Suppose the filter script reads a message from a particular file 
> and decides that it is spam. How does the filter tell Notmuch 
> that the message corresponding to that file is spam? You seem to 
> be saying below that the filter script should extract the 
> Message-ID and use it to identify the message to Notmuch, since 
> file paths of the messages are not indexed. Probably what my 
> script should be doing for each message is appending a line to a 
> batch file like this: 
> 
>      +spam -new -- id:some_message_id@foo +inbox -new -- 
>      id:some_other@baz 
> 
> and then passing the batch file to "notmuch tag"?

Yes, message ID is considered unique for each email, according to 
'src/database.cc':

    A mail document is associated with a particular email message. 
    It is stored in one or more files on disk and is uniquely 
    identified by its "id" field (which is generally the message 
    ID).

I remember that if there are multiple emails sharing a message ID, 
then they will share the same set of tags as well. At least that 
is the case if I add a duplicate message using 'notmuch insert'. 
 
> This time, I'm not sure I understand.

As mentioned above, they share the set of tags so I guess there is 
no need to bother.

> It might be useful for the reasons I stated, namely in case the 
> Message-ID does not exist or is not unique.

I suppose it does not help either in that case, because they are 
considered the same in the database. 
 
> Thank you for interpreting that section for me. The manual pages 
> may be informative and well written, but if my opinion matters, 
> then I think that they could be made slightly clearer than they 
> are.
> For example, explaining directly to the user that there is no 
> index of path names would help clarify what can be done with the 
> software.  Also, a short example of using Notmuch in a filter 
> script would be useful in one of the manual pages, particularly 
> illustrating the case where the programmer wants to re-tag a 
> message that is provided as a file or on stdin.
> 
> [...]
> 
> I see now that this text is only suggesting that Notmuch 
> supports searches for directory names, but on first read it 
> wasn't really clear to me whether "directory-path" means a "path 
> to a directory" or a "file path consisting of directories 
> followed by a filename", particularly as there is no obvious 
> reason for Notmuch not to index filenames. I think 
> "path:<directory>" would be clearer, and saying "The path: 
> prefix matches email messages that are stored in a specified 
> directory on the filesystem, which must be specified relative to 
> the top-level maildir, and here is how to find out what the 
> 'top-level maildir' is when you have for example 
> $HOME/mail/notmuch/ configured as your database path in 
> ~/.notmuch-config ...". Even clearer would be to explain why the 
> "path:" search prefix only accepts directories, point out that 
> it should be called "dir:" instead of "path:", and warn the user 
> that the search will be inefficient because there is no index of 
> filenames. 

Sorry that I assumed you had ignored that paragraph in the manual! 
I am not a native speaker so I have no opinions on the wording.

I am happy with the existing search terms, but using a custom 
filter script in query does sound useful, and I would love to see 
such an example if Notmuch already has support for that. Just my 
two cents.

Pengji
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: