Hi Adam,
Thanks for sharing. Just for reference, there are few major modes out
there implementing this kind of approach:
http://www.emacswiki.org/emacs/MultipleModes
For example I have used mmm-mode to good effect in the past, to
auto-switch between HTML and Perl:
http://mmm-mode.sourceforge.net/