Editing mixed-content files with multiple major modes in the same buffer
A buffer has a single major mode chosen according to the file format. For mixed-content files, there are ways to benefit from multiple major modes.
- mmm-mode, one of the ways to switch between major modes based on context
- polymode, another way to switch between major modes based on context
- Multiple Modes on the Emacs Wiki