multi-mode
Sometimes it is desirable to have different major modes in one
buffer. One such case occurs when editing comments in a
programming language buffer. Here it might be desirable to use a
totally different mode than the one used for editing the program
code itself.
I have adoped this practice for editing Prolog. The code itself is edited in prolog-mode, whereas the comments are edited in LaTeX-mode.
It is desirable to use different modes instead of enhancing one mode because much efford has already been put in various modes which needs not to be duplicated.
The multi-mode minor mode provides a means to accomplish such a feature.
The modes are described by initializing strings. I assume that certain tokens (i.e. transition strings) indicate the places where a new mode should be entered. To determine the mode at a point it is only neccessary to find the last transition string before point.
The desired modes are described in a list of pairs or triples consisting of a transition string and a mode (a symbol). Optionally a function symbol can be specified which is evaluated to activate the desired mode. Additionally the mode in absence of preceding transition strings has to be specified.

Download
