What is a simple way to combine two Emacs major modes, or to change an existing mode?

Posted by Winston C. Yang on Stack Overflow See other posts from Stack Overflow or by Winston C. Yang
Published on 2010-04-29T14:52:39Z Indexed on 2010/04/29 14:57 UTC
Read the original article Hit count: 309

Filed under:
|
|
|

In Emacs, I'm working with a file that is a hybrid of two languages.

Question 1: Is there a simple way to write a major mode file that combines two major modes?

Details:

  • The language is called "brew" (not the "BREW" of "Binary Runtime Environment for Wireless").

  • brew is made up of the languages R and Latex, whose modes are R-mode and latex-mode.

  • The R code appears between the tags <% and %>. Everything else is Latex.

  • How can I write a brew-mode.el file? (Or is one already available?)

One idea, which I got from this posting, is to use Latex mode, and treat the code of the form <% ... %> as a comment.

Question 2: How do you change the .emacs file or the latex.el file to have Latex mode treat code of the form <% ... %> as a comment?

© Stack Overflow or respective owner

Related posts about emacs

Related posts about dot-emacs