]> git.madduck.net Git - etc/neomutt.git/blob - .config/neomutt/reuse-message

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

datestamp tmpdir
[etc/neomutt.git] / .config / neomutt / reuse-message
1 #!/bin/sh
2 set -eu
3
4 eval mailfile="\${$#}"
5 editor=
6 for i in "$@"; do
7   # strip last argument from editor, yuk
8   case "$i" in
9     ("$mailfile") break;;
10     (*) editor="${editor:+$editor }$i";;
11   esac
12 done
13
14 tmpfile=$(mktemp --tmpdir reuse.XXXXXXXXXX)
15 cleanup() { rm -f "$tmpfile"; trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15; }
16 trap cleanup 1 2 3 4 5 6 7 8 10 11 12 13 14 15
17
18 formail -I Subject: < "$mailfile" | \
19   formail -I In-Reply-To: | \
20   sed -e '/^$/,/^-- /d' | \
21   sed -e '/^Bcc:/aSubject: ' > "$tmpfile"
22 cat "$tmpfile" > "$mailfile"
23
24 cleanup
25
26 if [ -n "$editor" ]; then
27   eval exec "$editor" "$mailfile"
28
29 # the last three replicate mutt's default (cf. manual)
30 elif [ -n "$VISUAL" ]; then
31   eval exec "$VISUAL" "$mailfile"
32 elif [ -n "$EDITOR" ]; then
33   eval exec "$EDITOR" "$mailfile"
34 fi
35 exec /usr/bin/editor "$mailfile"