notmuch-tagrewriter

Crates.ionotmuch-tagrewriter
lib.rsnotmuch-tagrewriter
version0.1.0
created_at2025-07-02 22:18:11.719729+00
updated_at2025-07-02 22:18:11.719729+00
descriptionRetag notmuch mails
homepagehttps://codeberg.org/xaltsc/notmuch-tagrewriter
repositoryhttps://codeberg.org/xaltsc/notmuch-tagrewriter
max_upload_size
id1735651
size138,986
xaltsc (xaltsc)

documentation

README

notmuch-tagrewriter

notmuch-tagrewriter is a small program that handles automatic tagging of notmuch 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

# 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 and other initial tagging methods.

notmuch-mailmover is also a rust rewrite of a feature of afew.

Commit count: 0

cargo fmt