procmail2notmuch: remove unprocessed when rule applies.

This commit is contained in:
Bill Thiede 2023-03-08 19:31:51 -08:00
parent 0d0a9d88ae
commit 332225b9d4

View File

@ -156,7 +156,9 @@ fn notmuch_from_rules<W: Write>(mut w: W, rules: &[Rule]) -> anyhow::Result<()>
continue;
}
lines.push(format!(
"+{} -- {}{}",
// TODO(wathiede): this assumes `notmuch new` is configured to add
// `tag:unprocessed` to all new mail.
"-unprocessed +{} -- tag:unprocessed {}{}",
t,
match m.match_type {
MatchType::From => "from:",
@ -188,7 +190,7 @@ fn notmuch_from_rules<W: Write>(mut w: W, rules: &[Rule]) -> anyhow::Result<()>
}
fn main() -> anyhow::Result<()> {
let input = "/home/wathiede/src/xinu.tv/letterbox/procmailrc";
let input = "/home/wathiede/dotfiles/procmailrc";
let mut rules = Vec::new();
let mut cur_rule = Rule::default();
for l in std::fs::read_to_string(input)?.lines() {
@ -230,6 +232,8 @@ fn main() -> anyhow::Result<()> {
'|' => cur_rule = Rule::default(), // external command
'$' => {
// TODO(wathiede): tag messages with no other tag as 'inbox'
cur_rule.tags.push(cleanup_match("", "inbox"));
rules.push(cur_rule);
cur_rule = Rule::default();
} // variable, should only be $DEFAULT in my config
_ => panic!("Unhandled first character '{}' {}", first, l),