From EmacsWiki: I have chunk problems with 1.99. This works, it detects the PHP and JS chunks properly: // EOTHTML; However if I don’t close the inner chunk before EOTHTML, because I want to add some conditional code after it in PHP then it thinks the part of the buffer after EOTHTML is still in JS mode which is not good: //