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