summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.fmail/.notmuch/hooks/post-new6
-rwxr-xr-xbin/movemymail22
2 files changed, 16 insertions, 12 deletions
diff --git a/.fmail/.notmuch/hooks/post-new b/.fmail/.notmuch/hooks/post-new
index dbd132d7..724096c9 100755
--- a/.fmail/.notmuch/hooks/post-new
+++ b/.fmail/.notmuch/hooks/post-new
@@ -2,12 +2,6 @@
. $HOME/.shenv
-# Mark all sent mail as read. mark it as unread first to ensure that
-# copies of the mail in other folders actually get their maildir Seen
-# flag added. This is a bug in notmuch; see id:87r1ypsb1p.fsf@tethera.net
-notmuch tag +unread -- folder:sent
-notmuch tag -unread -- folder:sent
-
# mark all drafts as drafts, and as read
notmuch tag -unread +draft -- folder:drafts
diff --git a/bin/movemymail b/bin/movemymail
index bb99686b..60919320 100755
--- a/bin/movemymail
+++ b/bin/movemymail
@@ -13,15 +13,16 @@ use Net::Domain "hostfqdn";
open our $us, "<", $0 or die $!;
exit 0 unless flock $us, LOCK_EX|LOCK_NB;
+our $root = "$ENV{HOME}/.fmail";
+our $on_athena = hostfqdn eq "athena.silentflame.com";
+
die "no movemymail\n" if -e "$ENV{HOME}/.nomovemymail";
-open my $df, "-|", "df", "-kP", "$ENV{HOME}/.fmail";
+open my $df, "-|", "df", "-kP", $root;
<$df>, my @df_fields = split " ", <$df>;
$df_fields[3] > 1048576 or die "free space low; no movemymail\n";
-our $on_athena = hostfqdn eq "athena.silentflame.com";
-
# Sync notmuch's database to maildir and to git.
-if (-d "$ENV{HOME}/.fmail/.notmuch/xapian") {
+if (-d "$root/.notmuch/xapian") {
# Skip on athena because it's v. slow atm.
system "mr", "-d", "$ENV{HOME}/lib/nmbug-spw", "autoci" unless $on_athena;
@@ -46,6 +47,15 @@ if ($on_athena) {
system "imap-dl", "$ENV{HOME}/.config/mailscripts/imap-dl.catmail";
}
+# Move all mail new/ -> cur/ such that notmuch never sees anything in new/.
+# The reason for this is that notmuch tries to avoid moving files new/ -> cur/
+# to avoid confusing Mutt, but messages in new/ aren't meant to have flags, so
+# they can't be marked seen. See id:87r1ypsb1p.fsf@tethera.net and maildir(5).
+for (<$root/*/new/*>) {
+ m#^\Q$root\E/([^/]+)/new/([^/]+?)(:2,[^/]*)?$# or die "inadequate glob!";
+ rename $_, "$root/$1/cur/$2" . ($3 || ":2,");
+}
+
# Useful to see if any mail has got stuck before closing laptop lid.
`mailq` =~ "Mail queue is empty" or warn "WARNING: Outbox not empty.\n";
@@ -55,11 +65,11 @@ sub search2folder {
"(", @terms, ")", "and", "not", "folder:$folder";
my @matches;
for (<$search>) {
- next if m{^$ENV{HOME}/.fmail/annex/};
+ next if m{^\Q$root\E/annex/};
chomp;
# If notmuch's database is out-of-date the file may no longer exist
# because it's already been moved by a previous run of this script.
-f and push @matches, $_
}
- @matches and system "mdmv", @matches, "$ENV{HOME}/.fmail/$folder";
+ @matches and system "mdmv", @matches, "$root/$folder";
}