How to delete and move email
Notmuch only indexes emails. They don’t modify any of your email in your Maildir folders.
This is mostly copied from other sites. However I am using OpenBSD and don’t have the GNU mv command with the -t flag to make life easy with the xargs command.
Edit: When I implemented emacs/notmuch helper scripts part II I had removed the “deleted” tag, since I wasn’t using it. By default notmuch will ignore any messages with this flag in a search. One thing I didn’t realize was this flag helps you visualize which messages are deleted in a thread with a lot of messages. I was just relying on the message residing in the Trash folder.
My emacs script now looks like:
(define-key notmuch-show-mode-map "d"
(lambda ()
"toggle deleted tag for message"
(interactive)
(if (member "move:trash" (notmuch-show-get-tags))
(notmuch-show-tag (list "-move:trash" "-deleted"))
(notmuch-show-tag (list "+move:trash" "+deleted" "-inbox" "-unread")))))
(define-key notmuch-search-mode-map "d"
(lambda ()
"toggle deleted tag for message"
(interactive)
(if (member "move:trash" (notmuch-search-get-tags))
(notmuch-search-tag (list "-move:trash" "-deleted"))
(notmuch-search-tag (list "+move:trash" "+deleted" "-inbox" "-unread")))))
My shell scripts look like:
notmuch_delete.sh:
/usr/local/bin/notmuch search --format=text0 --output=files "tag:deleted and not folder:Trash" | xargs -n1 -0 -r -t ~/bin/my_mv.sh ~/Maildir/Trash/cur/.
/usr/local/bin/notmuch new
my_mv.sh:
mv "$2" "$1"
Then after my Maildir sync program runs the message will be removed from the folder.
This can also be adopted to moving a message from one folder to another.