Change Emacs modes within specific tags
Asked Answered
S

3

7

OK, I know you're going to point me to EmacsWiki page, but here's the deal. I'd like to use the default Emacs mode for a given file type, and change mode after specific tag, say <% %>. By doing such, I can switch the mode inside the tags, and return to default mode when cursor is not inside tags.

And no, I don't need ASP/PHP mode, it just that I find boring M-x-ing all the time in order to change the mode. I'm using Emacs 23.2.1 on Arch Linux FWIW. Any ideas?

Sassenach answered 24/1, 2011 at 19:43 Comment(0)
A
6

Have a look at mmm-mode: http://sourceforge.net/projects/mmm-mode/ or noweb-mode. Here are instructions for getting mmm-mode to work with literate Haskell documents. And here is the configuration I use for noweb-mode with literate (rst+python) Python documents.

Anole answered 24/1, 2011 at 20:8 Comment(2)
I don't like mmm-mode, I find it hard to configure, but noweb-mode is a great find, especially 'cause I use it for Sweave (R + LaTeX). Thanks!Sassenach
The mmm-mode archive also contains the manual in texinfo format so you can convert it also to pdf if you wan't: texi2pdf mmm.texinfoAnole
A
1

nXhtml

nXhtml is an addon to Emacs for editing XHTML, PHP and similar things.

nXhtml comes with MuMaMo (Multiple Master Major Mode), which I think is a newer version of mmm-mode. I use it all the time when editing Django HTML files which combine CSS, JavaScript and Django-aware HTML modes.

Anagrammatize answered 25/1, 2011 at 0:57 Comment(2)
I don't need a plugin for webdev. I used nXhtml for a while, but I'm not using it anymore, and the only way to use MuMaMo is to use nXhtml. So it's a no-no for me...Sassenach
"Multiple Major Modes", more accurately. MuMaMo is supplied as part of nXhtml, but I would be extremely surprised if it could not be used separately from nxhtml-mode.Thurmanthurmann
G
0

Is it what are you looking for :

http://www.emacswiki.org/emacs/PhpMode#toc8

You probably want to adapt it to fit your need

Gyrostatic answered 24/1, 2011 at 22:52 Comment(1)
I don't want to bind mode change to a keypress, I want to change modes automatically within a buffer, so tags can act as triggers. But thanks anyway... =)Sassenach

© 2022 - 2024 — McMap. All rights reserved.