]> git.madduck.net Git - etc/mutt.git/blob - .mutt/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:

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