afewmail / afew

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

--enable-filters not behaving as expected #306

Open xaltsc opened 3 years ago

xaltsc commented 3 years ago

Hey,

Perhaps I misunderstood the documentation, but I've got this piece in my config, which should be minimal enough, and with the aim of using it not on new messages, but only on old messages.

[AllFilter(Filter)]
  tags_blacklist = new
  message = Running on all messages (allegedly)

[AllFilter.0]
  query = tag:archive or tag:killed or tag:sent
  tags = -inbox;-unread
  message = De-inboxing and reading archived, killed and sent messages

However, when running afew -d --tag --all -vv -e 'AllFilter' -R 100000000000000 -T 1000000000000000000000000, the output I get is this below, meaning that AllFilter.0 has not been taken into account.

INFO:afew.Settings.AllFilter:Running on all messages (allegedly)
DEBUG:root:Executing query ''

Note, however, that AllFilter.0 is run when dropping the -e option.

xaltsc commented 3 years ago

Defining the class in a Python file like below doesn't work either.

@register_filter
class AllFilter(Filter):
    message = 'Running on all messages (allegedly)'
    tags_blacklist = "new"
GuillaumeSeren commented 3 years ago

Hey @xaltsc , welcome to the project.

the aim of using it not on new messages, but only on old messages

This can be done, by using a notmuch query (https://www.mankier.com/7/notmuch-search-terms#Date_and_Time_Search), like:

# Select only the last year mails
$ afew --tag date:2Y..1Y

Defining the class in a Python file like below doesn't work either.

I suppose that's because it should be defined in the config file.

Please copy you config, that we can check it, try to call you filter without -R or -T but only notmuch query, also please copy a verbose output (relevant part) of the afew call.

mjg commented 1 year ago

Old bug, but probably same root cause as I just encountered: selecting filters with -e does not seem to take the options from config into account. This is unfortunate if you want to run a newly configured filter on old e-mails.

mjg commented 1 year ago

And sure enough this is ussue #40 which I even commented on back then ... Oh well. I guess I don't need -e often, but when I do, I fall into the config trap.