How to use two modes in emacs (markdown and auctex)

emacs

When I edit markdown in emacs I use markdown-mode. However I often have to type some math formulas in the markdown file (processed by mathjax). However for those math parts markdown mode is not very comfortable.

Is there a way to make emacs automatically switch to latex (auctex) mode (locally) when the point is between two $ signs for example ($\mathbb{R}$) or between two double $ signs for example

$$
\begin{align}
a = b
\end{align}
$$

?

Edit
I also want to have the font locking of the "local" mode.

Edit 2
I tried mmm-mode, but this doesn't handle font-locking correctly. I guess that multi-mode.el or MuMaMo-mode might be what I want. But I didn't figure out how to use this in my examples. So, if it is possible to do what I want with one of this or with another mode, it would be great if someone could post detailed steps howto apply it in my case as an answer.

Best Answer

Emacs has several packages that help switching quickly and automatically between modes. The Emacs wiki has a page on multiple modes.

Mmm-mode is a common choice, but I expect each of the possibilities to have its ups and downs.

Related Question