7

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.

echristopherson
  • 6,974
  • 2
  • 21
  • 31
Winston C. Yang
  • 1,497
  • 2
  • 18
  • 27

1 Answers1

6

A number of folks have written solutions enabling you to use multiple major modes at once. See the Emacs Wiki for Multiple Modes. I personally have no experience with them and cannot recommend one over another.

Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
  • 1
    I've worked with MuMaMo in nxhtml and it works pretty well most of the time. – Bozhidar Batsov Apr 29 '10 at 16:57
  • @Trey: thank you for the link. I changed the two-mode-mode.el file there, and got it to work. But in Latex mode (not R mode), the minibuffer was constantly printing messages. Possibly Emacs was in an infinite loop. I used Aquamacs (Emacs) 1.9 on Mac OS 10.6.3. Your experience with two-mode-mode might differ. @Bozhidar: Thank you for the information. – Winston C. Yang May 01 '10 at 15:57