summaryrefslogtreecommitdiff
path: root/.fmail
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2017-06-12 13:33:20 +0100
committerSean Whitton <spwhitton@spwhitton.name>2017-06-12 13:33:20 +0100
commita6b7a44f8649218c7b8b298490be70e717e87498 (patch)
tree561d0bf61258b4f2d01e92fe15162ca3e812f670 /.fmail
parent800f5410216722a78702c246ae2daf35c64ec832 (diff)
downloaddotfiles-a6b7a44f8649218c7b8b298490be70e717e87498.tar.gz
move mail between folders before running notmuch new
This ensures that notmuch is aware of where every message is to be found.
Diffstat (limited to '.fmail')
-rwxr-xr-x.fmail/.notmuch/hooks/post-new33
-rwxr-xr-x.fmail/.notmuch/hooks/pre-new39
2 files changed, 40 insertions, 32 deletions
diff --git a/.fmail/.notmuch/hooks/post-new b/.fmail/.notmuch/hooks/post-new
index 5e1ef6c9..c8532d44 100755
--- a/.fmail/.notmuch/hooks/post-new
+++ b/.fmail/.notmuch/hooks/post-new
@@ -1,46 +1,15 @@
#!/bin/sh
-# The primary purpose of this script is to maintain the 'draft',
-# 'spam' and 'unread' tags such that the only data in the notmuch
-# database that cannot be reproduced from the Maildir is which threads
-# have been killed, which is not important information. Then there is
-# no need to sync the notmuch database between machines. Syncing the
-# maildir with mbsync(1) is sufficient.
-
-# Note that another aspect of this setup is not using an 'inbox' tag.
+. $HOME/.shenv
# mark all sent mail as read
notmuch tag -unread -- folder:sent
-# ensure all drafts are in the drafts folder
-floating_drafts=$(notmuch search --output=files -- tag:draft and not folder:drafts)
-if [ ! -z "$floating_drafts" ]; then
- mdmv $floating_drafts $HOME/.fmail/drafts
-fi
-
# mark all drafts as drafts, and as read
notmuch tag -unread +draft -- folder:drafts
-# propagate the 'killed' tag to all messages in the killed message's thread
-killed_threads=$(notmuch search --output=threads tag:killed)
-if [ ! -z "$killed_threads" ]; then
- notmuch tag -unread -- $killed_threads
-fi
-
-# ensure all spam is in the spam folder to train FastMail's spam filter
-floating_spam=$(notmuch search --output=files -- tag:spam and not folder:spam)
-if [ ! -z "$floating_spam" ]; then
- mdmv $floating_spam $HOME/.fmail/spam
-fi
-
# mark all spam as spam
notmuch tag +spam -- folder:spam
-# ensure all deleted messages are in the trash folder
-floating_deleted=$(notmuch search --output=files -- tag:deleted)
-if [ ! -z "$floating_deleted" ]; then
- mdmv $floating_deleted $HOME/.fmail/trash
-fi
-
# mark all trash as trash
notmuch tag +deleted -- folder:trash
diff --git a/.fmail/.notmuch/hooks/pre-new b/.fmail/.notmuch/hooks/pre-new
index 037e20de..6af993dd 100755
--- a/.fmail/.notmuch/hooks/pre-new
+++ b/.fmail/.notmuch/hooks/pre-new
@@ -2,4 +2,43 @@
. $HOME/.shenv
+# The primary purpose of my pre-new and post-new scripts is to
+# maintain the 'draft', 'spam', 'deleted' and 'unread' tags such that
+# the only data in the notmuch database that cannot be reproduced from
+# the Maildir is which threads have been killed, which is not
+# important information. Then there is no need to sync the notmuch
+# database between machines. Syncing the maildir with mbsync(1) is
+# sufficient.
+
+# Note that another aspect of this setup is not using an 'inbox' tag.
+
+# In this script, we move mail according to tags that may have been
+# added since the last 'notmuch new' run. Then we sync with my IMAP
+# server. Then in the post-new script we add tags to new messages in
+# particular folders
+
+# ensure all drafts are in the drafts folder
+floating_drafts=$(notmuch search --output=files -- tag:draft and not folder:drafts)
+if [ ! -z "$floating_drafts" ]; then
+ mdmv $floating_drafts $HOME/.fmail/drafts
+fi
+
+# propagate the 'killed' tag to all messages in the killed message's thread
+killed_threads=$(notmuch search --output=threads tag:killed)
+if [ ! -z "$killed_threads" ]; then
+ notmuch tag -unread -- $killed_threads
+fi
+
+# ensure all spam is in the spam folder to train FastMail's spam filter
+floating_spam=$(notmuch search --output=files -- tag:spam and not folder:spam)
+if [ ! -z "$floating_spam" ]; then
+ mdmv $floating_spam $HOME/.fmail/spam
+fi
+
+# ensure all deleted messages are in the trash folder
+floating_deleted=$(notmuch search --output=files -- tag:deleted and not folder:trash)
+if [ ! -z "$floating_deleted" ]; then
+ mdmv $floating_deleted $HOME/.fmail/trash
+fi
+
movemail