Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Emacs modes within specific tags

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?

like image 439
aL3xa Avatar asked Jan 24 '11 19:01

aL3xa


People also ask

How do I change modes in Emacs?

Usually, the major mode is automatically set by Emacs, when you first visit a file or create a buffer (see Choosing File Modes). You can explicitly select a new major mode by using an M-x command.

How do I use tags in Emacs?

' ( 'find-tag' ) – find a tag, that is, use the Tags file to look up a definition. If there are multiple tags in the project with the same name, use ` C-u M-. ' to go to the next match. 'M-x find-tag-other-window' – selects the buffer containing the tag's definition in another window, and move point there.

How do I enable minor mode in Emacs?

If you want to enable/disable minor-modes on the whole session, press [e] or [d] on any minor-mode to keep its status even if you change major-modes, buffers, files. It continues until stopping emacs. This enable/disable list is stored in the global of manage-minor-mode-default .

How do I use Ctags in Emacs?

To use ctags with emacs, you must supply the '-e' parameter to instruct ctags to generate an emacs tag file. The commands below are often sourced into a Makefile and then run with a CompileCommand. Ctags also has a recursive option, '-R' . This is the most common (and simple) usage.


2 Answers

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.

like image 102
Matti Pastell Avatar answered Oct 05 '22 09:10

Matti Pastell


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.

like image 43
a paid nerd Avatar answered Oct 05 '22 09:10

a paid nerd