Getting Flymake to work with Emacs nXhtml

If you develop in PHP on Emacs, then you’ve probably got a hook setup to run flymake-mode on PHP files. And if so, then you’ve also probably noticed that this doesn’t work with nXhtml, which will often return an error like “mumamo can’t find the file” (or some such), causing flymake-mode to disable itself.

The culprit is likely to be a bind like this:

(add-hook 'php-mode-hook (lambda () (flymake-mode t)))

which says, “turn on flymake-mode when php-mode is started”. (Sacha Chua has a post that recommends using this from couple of years back.) The problem, as far as I can tell, is that nXhtml tries to process the fleetingly available _flymake file rather than the original PHP script whenever it toggles into php-mode.

A better hook to use is the find-file-hook, like this:

(add-hook 'find-file-hook 'flymake-mode)

With this, Flymake will properly validate PHP chunks in nXhtml mode, as well as any other files that Flymake is smart enough to process.

Tags: ,

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

3 Responses to “Getting Flymake to work with Emacs nXhtml”

  1. Sacha Chua Says:

    Oh, even better. Thanks for sharing! =)

  2. Adam Says:

    Thanks for this heads up!

    I’ve been running into this issue all morning until I saw that it was MuMaMo and Flymake who were at odd ends. Now I can stop focusing on that and get back to finishing my code 🙂


  3. vineet Says:

    That’s just what I was looking for.
    Thanks for providing the explanation as well. It really helped

Leave a Reply