teythoon/afew — pull request #46 by pazz (2013-04-02 12:56:57+00:00)
Title: HeaderMatchingFilter

This Filter allows to set tags based on a messages header value matching a given regular expression.

It allows for substring substitution in the constructed tagstring based on (named) parts in the actual header value. The current `SpamFilter` and `ListMailsFilter` could be replaced by trivial subclases of this Filter class.

example config:
```
[HeaderMatchingFilter.0]
header = List-Id
pattern = (?P.*)
tags = +{lid}
message = add value of List-Id as tag
```

Comment:
The line
```
value = message.get_header(self.header)
```
should better be something along the lines of
```
values = message.get_all_header(self.header)
```
to cater for the possibility of multiple header values for the same key.
This is not part of notmuchs API atm.