afewmail / afew

an initial tagging script for notmuch mail
ISC License
325 stars 98 forks source link

Docs should suggest InboxFilter be last (usually) #254

Open ryantate opened 4 years ago

ryantate commented 4 years ago

Thank you for afew, it is a pretty excellent system to use in conjunction with notmuch! On to my little issue here:

Perhaps I am not so smart but it took me a lot of time debugging before I realized that the filters I added to my config were not being executed on afew --tag --new because I had put them under the defaults, and the last default is InboxFilter.

InboxFilter of course removed the "new" tag from each message encountered so the filters underneath it never got any messages to run on because all the new ones had been stripped of their "new" tags and only new messages are sent to filters when youu run afew --tag --new.

Staring at the source code and running some tests with the logger, I finally realized that 1> each filter runs a fresh search against the database to get new messages and 2> the default query for that search is (tag:new) . Even if you add a query particular to the filter, this query is run in combination, like: (tag:new) AND (myquery goes here).

This is all perfectly reasonable if you are aware of it but it might save some other people some pain if the docs remind people of the impact of putting anything below InboxFilter. Some people might subconsciously assume, as I did, that all the filters work on the same set of messages, and not realize a fresh search is run to feed each filter with the results of (tag:new), at least when running the common afew --tag --new command.

Due to this rather split nature of the Filters documentation -- half seems to be on the Configuration page and half on a dedicated Filter page -- I suggest putting such a warning on both pages:

  1. high up on the Configuration page, under the sentence "See the Filters page for the details of those filters and the custom arguments they accept.", maybe put a sentence like, "(The Filters page also explains why you'll probably want to put any filters you define above the InboxFilter.) "
  1. on the Filters page, maybe add a new sentence at the end of the InboxFilter section: "Note that InboxFilter will stop further processing of messages if running under afew --tag --new, which feeds filters only those messages tagged as new."

Thanks for considering.