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.
You can change to a different major mode by executing its command. For TextMode (indicated by “Text” in the mode-line), for example, do 'M-x text-mode' . You can use 'C-h m' for help on the current major mode, and 'C-h b' to see all the bindings in effect.
A mode is a set of definitions that customize Emacs behavior in useful ways. There are two varieties of modes: minor modes, which provide features that users can turn on and off while editing; and major modes, which are used for editing or interacting with a particular kind of text.
The standard default value is fundamental-mode . If the default value is nil , then whenever Emacs creates a new buffer via a command such as C-x b ( switch-to-buffer ), the new buffer is put in the major mode of the previously current buffer.
If you invoke the mode command directly with no prefix argument (either via M-x , or by binding it to a key and typing that key; see Customizing Key Bindings), that toggles the minor mode. The minor mode is turned on if it was off, and turned off if it was on.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With