Installing Emacs MMM-Mako Mode

For my job at Hulu this summer, I’ve been developing a RESTful web service and web based frontend using CherryPy and Mako Templates. Since Mako uses a mix of its own syntax, HTML and Python, syntax highlighting won’t work out of the box in Emacs. Enter MMM (Multiple Major Mode) Mode, which allows for multiple Emacs major modes within one buffer, and MMM-Mako Mode which provides support for Mako files using MMM. Getting these set up was somewhat problematic, so I’m going to document the process for anyone else trying to get these working.

(I assume python-mode is already working)

  1. Download and untar MMM Mode from I’m using version 0.4.8.
  2. Make and install MMM Mode. You need to specify where your Emacs is installed. I use Gnu Emacs 23, which I have installed in the /Applications directory.
    sudo make install

    The elisp files were installed to /usr/local/share/emacs/site-lisp in my case. You may need to add this directory to the Emacs load path. You will also need to tell Emacs to load the module. I added this to my .emacs:

    (add-to-list 'load-path "/usr/local/share/emacs/site-lisp")
    (require 'mmm-auto)
    (setq mmm-global-mode 'maybe)

    Make sure it installed correctly by opening up Emacs and typing M-x mmm-mode to turn on MMM-Mode.

  3. Now you’ll want to download MMM-Mako from Follow instructions as in the README, pointing Emacs to the mmm-mako.el file. I added to my .emacs:
    (add-to-list 'auto-mode-alist '("\\.mako\\'" . html-mode))
    (mmm-add-mode-ext-class 'html-mode "\\.mako\\'" 'mako)
  4. At this point, everything is configured for MMM-Mako, and opening a .makofile should enable MMM-Mode. If you open a file with both Python and HTML, however, you will probably see an error:
    mmm-format-string: Wrong type argument: stringp, (sgml-xml-mode "XHTML" "HTML")

    A bug report explains why this is happening in Emacs 23 and offers a fix. Find the mmm-utils.el file from your MMM-Mode installation and apply the patch from the bug report, or edit it by hand.

    sudo patch /usr/local/share/emacs/site-lisp/mmm-utils.el fix_mmm-format-string.diff

    You’ll want to byte-compile the modified file, so open up Emacs again and type M-x byte-compile-file and provide it with the location of your mmm-utils.el file. You may need to do this with root privileges depending on where you installed the MMM-Mode files.

At this point you should have a fully functioning MMM-Mako Mode.

All the additions to my .emacs file:

(add-to-list 'load-path "/usr/local/share/emacs/site-lisp")
(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
(load "src/mmm-mako.el")
(add-to-list 'auto-mode-alist '("\\.mako\\'" . html-mode))
(mmm-add-mode-ext-class 'html-mode "\\.mako\\'" 'mako)

About Zachary Wasserman

Currently working on
This entry was posted in Emacs and tagged , , , . Bookmark the permalink.

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