Why are there validation errors in my mixed mode file?

Created by lborgman on on 2010-04-23
Keywords:
mumamo validation
Last updated by:
lborgman on on 2010-04-23

A common question is why there are validation errors in multi major mode buffers. There usually are in for example in a django file using

  django-nxhtml-mumamo-mode

The answer to this is that the validation in this case is written to take care of the whole file. When we borrow it to use it in multi major mode buffers the validation still want to take care of the whole buffer. Since the validator in this case checks if the buffer contains valid XHTML code it of course find that there are errors if the django file does not happen to be valid XHTML (which it normally is not).

You can get rid of those errors by instead using

  django-html-mumamo-mode

The difference is that it uses html-mode (which does not have a validator) instead of nxhtml-mode (which has a validator) for the html parts. For all multi major modes in nXhtml which has html as the main part there is one with a validator and one without it. You can see on the name which has the validator and which does not have it, just as for the example above.

With no validator there is of course no validation errors. In fact for Emacs 22 it is strongly recommended that you do not use the validating multi major modes. For Emacs 23 there is a better chance that they work, but they can still create trouble sometimes. If they do just switch to the non-validating multi major mode for your kind of file.

Why are there then validating multi major modes? What use do they have?

The answer is that they also provide completion for the part that is validated. (Currently the only example is XHTML/XML.)

In the future I hope we can base those validating single major modes on CEDET and integrate them better with multi major modes. But that requires integration of CEDET and mumamo.el which is not yet done. (And it also requires that those modes uses the parser builder that comes with CEDET, ie Wisent which I hope can be integrated with mumamo.el.)

Another approach would be to change the core of Emacs to better take care of multi major mode. A possible solution might then be to hide the parts of the buffer from validator that it does not know of. But this is an even more long term goal then CEDET integration.