notmuch-tagrewriter 0.1.0

Retag notmuch mails
Documentation
# notmuch-tagrewriter

`notmuch-tagrewriter` is a small program that handles automatic tagging of
[notmuch](https://notmuchmail.org) messages. The main focus of this
program is to provide an idempotent behaviour: the final state is reached in a single execution
and successive runs don't produce different database states.

## Usage

Define rules in the config file (default path is
`$XDG_CONFIG_DIR/notmuch-tagrewriter/config.yaml`, then run
`notmuch-tagrewriter tag`.

```
Usage: notmuch-tagrewriter [OPTIONS] [COMMAND]

Commands:
  graph   Print a graphviz dot representation of the rewriting rules
  cycles  Find cycles in the set of rules
  tag     Rewrite tags
  help    Print this message or the help of the given subcommand(s)

Options:
  -c, --config <FILE>  Set config file
  -h, --help           Print help
```

### Example `config.yaml`

```yaml
# whether to track last commit and only run on messages changed since last commit. False if omitted
track_lastmod: false
# defaults to notmuch default if omitted
notmuch_config: /path/to/notmuch/config
rules:
    # queries are standard notmuch queries, but only tag predicates
    # are allowed
  - query: tag:a and tag:b or (not tag:c)
    rewrite: +c -a
    name: add c tag and remove a
  - query:
      # query can also be a list, in which case this is interpreted as
      # query1 OR query2 OR ...
      - tag:a and tag:b
      - not tag:c
    rewrite: +d
    name: list rule
```

## Limitations

By design, `notmuch-tagrewriter` can only query for tags and act on
them. This is a limitation of the underlying model used to ensure
idempotence and why this tool just rewrites tags. In order to act on
tags, you still have to set them using broader queries in your
post-new hook.

# Related projects

`notmuch-tagrewriter` was born out of frustration with [afew](https://github.com/afewmail/afew)
and other initial tagging methods.

[`notmuch-mailmover`](https://github.com/michaeladler/notmuch-mailmover) is also a rust rewrite of
a feature of afew.