Here you have something that works. Doesn’t do anything fancy (in fact it is useless), but I guess you could adapt it to suit your needs:
macro index T "<enter-command>unset wait_key\n \ <pipe-message>cat - > /home/ferdy/foo.blah\n \ <shell-escape>vim -c 'set ft=mail' /home/ferdy/foo.blah\n \ <enter-command>set wait_key\n"
I tried using ‘decode-save’ and/or ‘save-message’ but for some reason it didn’t work. I guess you could replace ‘x.sh’ or almost all of it with a mutt macro like the one above.