From 332225b9d437b043d6e5c677e762cdd6c6f7cae4 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Wed, 8 Mar 2023 19:31:51 -0800 Subject: [PATCH] procmail2notmuch: remove unprocessed when rule applies. --- procmail2notmuch/src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/procmail2notmuch/src/main.rs b/procmail2notmuch/src/main.rs index f3108bd..a6759b7 100644 --- a/procmail2notmuch/src/main.rs +++ b/procmail2notmuch/src/main.rs @@ -156,7 +156,9 @@ fn notmuch_from_rules(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(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),