macro index S "<tag-prefix><save-message>=store<enter><sync-mailbox>" "save messages to store"
macro pager S "<save-message>=store<enter><sync-mailbox>" "save message to store"
-macro index \er '<tag-prefix><save-message>=resubmit<enter><sync-mailbox>' "resubmit messages"
-macro pager \er '<save-message>=resubmit<enter><sync-mailbox>' "resubmit message"
-
macro index,pager E '<enter-command>source "$my_confdir/supersede-header X-Tickle get-timestamp|"<enter><next-undeleted><enter-command>push \er<enter>' "schedule messages with tickler"
macro index,pager \ex '<enter-command>source "$my_confdir/remove-header X-Postponed|"<enter>' "release postponed messages"
macro index \ej '<enter-command>set my_editor="$editor"<enter><enter-command>source "$my_confdir/batch-subject-editor|"<enter><tag-prefix><edit><enter-command>set editor="$my_editor"<enter>' "change message subject"
+macro index,pager \er '<enter-command>set my_editor="$editor"<enter><enter-command>set editor="~/.mutt/reuse-message $my_editor"<enter><reply><enter-command>set editor="$my_editor"<enter>' "invoke normal editor to edit message"
+macro index,pager \eg '<enter-command>set my_editor="$editor"<enter><enter-command>set editor="~/.mutt/reuse-message $my_editor"<enter><group-reply><enter-command>set editor="$my_editor"<enter>' "invoke normal editor to edit message"
+macro index,pager \el '<enter-command>set my_editor="$editor"<enter><enter-command>set editor="~/.mutt/reuse-message $my_editor"<enter><list-reply><enter-command>set editor="$my_editor"<enter>' "invoke normal editor to edit message"
+
macro index <F8> "<enter-command>unset wait_key<enter><shell-escape>~/.mutt/mutt-notmuch --prompt search<enter><change-folder-readonly>~/.cache/mutt_results<enter>" "search mail (using notmuch)"
macro index <F9> "<enter-command>unset wait_key<enter><pipe-message>~/.mutt/mutt-notmuch thread<enter><change-folder-readonly>~/.cache/mutt_results<enter><enter-command>set wait_key<enter>" "search and reconstruct owning thread (using notmuch)"
--- /dev/null
+#!/bin/sh
+set -eu
+
+eval mailfile="\${$#}"
+for i in "$@"; do
+ # strip last argument from editor, yuk
+ case "$i" in
+ ($mailfile) break;;
+ (*) editor="${editor:+$editor }$i";;
+ esac
+done
+
+tmpfile=$(tempfile -p reuse)
+cleanup() { rm -f "$tmpfile"; trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15; }
+trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15
+
+formail -I Subject: < "$mailfile" | \
+ formail -I In-Reply-To: | \
+ sed -e '/^$/,/^-- /d' | \
+ sed -e '/^Bcc:/aSubject: ' > "$tmpfile"
+cat "$tmpfile" > "$mailfile"
+
+if [ -n "$editor" ]; then
+ eval exec "$editor" "$mailfile"
+elif [ -n "$VISUAL" ]; then
+ eval exec "$VISUAL" "$mailfile"
+elif [ -n "$EDITOR" ]; then
+ eval exec "$EDITOR" "$mailfile"
+fi
+exec /usr/bin/editor "$mailfile"