domo141 / nottoomuch

Misc material I use with notmuch mail indexer
32 stars 3 forks source link

[RFE] Allow excluding addresses from particular folders #1

Closed suvayu closed 10 years ago

suvayu commented 10 years ago

It would be really nice if I could exclude addresses from specific maildirs. I would like to exclude all email addresses from mailing list posts.

I had a quick look at the script (I do not speak Perl) and it seemed output of 'notmuch search' is being parsed. If so, allowing to add an arbitrary search substring might be cool. But then that probably means lots of "user bug" reports that you have to respond with NOTABUG. I do not know what is the best way to do this, but having the feature to ignore maildirs would be great.

Thanks for your work, I use it all the time (from mutt-kz).

domo141 commented 10 years ago

I put this into consideration and I already thought a way or two to implent it.

But check also 'IGNORE FILE' section in nottoomuch-address --help output. How much of your issues are solved by just adding a few ingore rules there ?

suvayu commented 10 years ago

I have considered this; I'm not sure I can reduce the noise with rules. Here is my use case: I'm subscribed to many FOSS lists, I also belong to a large (> few 100s) international scientific collaboration. So the list of addresses involved are quite large and varied (as in it does not fit into a nice ignore/accept pattern).

Now I keep all frequently emailed contacts in my mutt alias file (it's getting quite long already, ~80). I would like to be able to use nottoomuch as the address book for the not-so-frequently-emailed or "never emailed but I will in the future" contacts. The latter happens quite often with such a large scientific collaboration.

Currently the database has about 12000 addresses. The only way I can see the present ignore rule based trick working is by copying over all addresses I won't need. But that is tedious; sometimes it is even impossible to determine since I can't tell where the email address comes from. Of course if you can think of a nice idea to write even partially effective rules, I would love to try it.

domo141 commented 10 years ago

OK, I'll see what can be done there...

domo141 commented 10 years ago

Now nottoomuch-addresses.sh in dogfood branch has --exclude path[::path[::path...]] option; i.e. multib paths are separated with 2 ::s (as : can be used in regexp). Also separate paths can be given with many --exclude options...

the "path" is actually regular expression ancored from beginning but not end; database.path is prepended to the re internally (the technical reason to anchoring...)

an example:

one has mails in $HOME/mail/received $ $HOME/mail/sent/ (database.path is $HOME/mail)

nottoomuch-addresses.sh --update --rebuild --exclude=sent will exclude sent ( and all its subdirectories, but would not $HOME/mail/drafts/sent...)

I am pretty sure this works well, but I don't have enough material to test more throughly, I hope that you, Suvayu (or is it Ali :) could do some testing ;D

suvayu commented 10 years ago

Sorry for the delay, I tested this today. It seems to work quite well. I presume the --exclude flag is required only for the rebuild, subsequent updates retain the set of excluded maildirs (at least that's what I got from my testing :-P)? After excluding mailing lists, my database is now 5200 something. From a cursory look I think it only has addresses I want. :+1:

PS: I respond to both Suvayu and Ali, although Suvayu is my first name :)

domo141 commented 10 years ago

Good that it works. Indeed the exclude flag is only required for the rebuild (ignored when updated, as you can see the tool printing). The list of excluded directories are stored at the beginning of ~/.config/nottoomuch/addresses