Multiple modes for mxml and Actionscript in Emacs

Flexing in Emacs again… Emacs 22 supports the entertainingly named MuMaMo mode which allows support for Multiple Major Modes. This is useful for editing MXML files that mix XML markup with Actionscript.

I am using MuMaMo together with actionscript-mode and nxml-mode with this definition in my .emacs:

(defun mumamo-chunk-mxml-script (pos min max)
"Find ... , return range and actionscript-mode."
(mumamo-quick-static-chunk pos min max "" "" nil 'actionscript-mode nil))

(define-mumamo-multi-major-mode mxml-actionscript-mumamo-mode
"Turn on multiple major modes for MXML files with main mode `nxml-mode'.
This covers inlined Actionscript."
("MXML Actionscript Family" nxml-mode

(add-to-list 'auto-mode-alist '("\\.mxml$" . mxml-actionscript-mumamo))


2 responses to “Multiple modes for mxml and Actionscript in Emacs

  1. Hi, in case anyone else is new to MuMaMo and is having trouble getting this to work (I was), I’ve found that you need to fill in those two empty strings with the beginning and ending tags for the Actionscript part. Here’s what mine looks like:

    (mumamo-quick-static-chunk pos min max “” “” nil ‘actionscript-mode nil))

    And of course, you need to include the MuMaMo start script. I just grabbed the nXHTML package and am using it through that. If you’re using Emacs 23 or greater, load “nxhtml/autostart.el”. If you’re using Emacs 22 load “nxhtml/autostart22.el” and edit it to point to nXML (which you’ll have to get separately in that case).

    Another tip — Turn off the MuMaMo background colors:
    (setq mumamo-background-colors nil)

    This was a huge help for me; my thanks to the author of this article!


    The Script tags that I included above were automatically edited out when I posted (and I bet they were edited out in the original post as well). The line should look like this:

    (mumamo-quick-static-chunk pos min max “(Script)” “(/Script)” nil ‘actionscript-mode nil))

    Except use the standard XML-style angle brackets instead of those parenthesis.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s