Hi Frederick,
Frederick Eaton <frede...@ofb.net> writes:
I am trying to figure out how to adapt a script I wrote for
filtering messages, to apply notmuch tags to each message. A
difficulty is that the messages are already in the Notmuch
database, because another tool has delivered them to a maildir
and run "notmuch new".
Now, Notmuch can provide me with the paths of all the new
(unfiltered) messages, which I can give to my script. The
question I have is, once the filter is done, how can the script
tell Notmuch which message to apply the tags to?
I am not sure if I understand you correctly. If the problem here
is to distinguish existing messages and new messages, would the
config option 'new.tags' work? For example, use
notmuch config set new.tags new
to give all new messages a 'new' tag.
I've tentatively concluded that the best way to locate each
message in the Notmuch database is to extract the Message-ID and
search for it with "id:"? But the FAQ says that multiple
messages can have the same Message-ID (and some spam messages
don't have one at all).
IIRC, in the Notmuch database tags are associated with message
IDs, so you probably do not need to worry about this.
If I could access the message using the filename that the script
is processing, it would seem slightly more reliable. It seems
like there should be some way to allow a Notmuch database entry
to be accessed directly by filename, without even creating a
Notmuch-style search query containing that filename, but rather
by passing the filename as a command-line argument to "notmuch".
It would be nice not to have to worry about quoting and
unquoting.
I am not sure if this is useful, given that (presumably) Notmuch
uses message IDs as keys. Besides, those filenames are usually
generated automatically and quite cryptic.
When I try to search for a message using "path:", nothing seems
to work.
[...]
There were no results for any of the "path:" searches, although
the "id:" search worked. I am using version 0.32.2 and can
update if this may be related to a bug that was fixed in the
past few years.
I have never used 0.32.2 so I am not sure if there are any
differences, but for version 0.38.3, the prefix "path:" is used to
search for messages in some *directory*, and the query should be
*relative* to the maildir.
I highly recommend the manual page 'notmuch-search-terms(7)' and
also other pages if you have time. They are informative and well
written, and very helpful for writing message processing scripts.
Regards,
Pengji
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org