MultipleModes

Last edit

Summary: Update the "last update" values.

Changed:

< || web-mode || 1 || 364 kb || 2014-11-02 || http://web-mode.org ||
< || polymode || 7 || 120 kb || 2014-05-07 || https://github.com/vitoshka/polymode ||
< ||
mmm-mode || 17 || 185 kb || 2013-10-27 || https://github.com/purcell/mmm-mode ||

to

> || web-mode || 1 || 364 kb || 2014-11-21 || http://web-mode.org ||
> || mmm-mode || 17 || 185 kb || 2014-11-04 || https://github.com/purcell/mmm-mode ||
> || polymode || 7 || 120 kb || 2014-06-14 || https://github.com/vitoshka/polymode ||

Changed:

< (as of 2014-01-19)

to

> (as of 2014-11-24)


Libraries providing multiple MajorModes in a buffer. See also MinorMode.

Comparison

library elisp files size last update url
web-mode 1364 kb 2014-11-21http://web-mode.org
mmm-mode 17185 kb 2014-11-04https://github.com/purcell/mmm-mode
polymode 7120 kb 2014-06-14https://github.com/vitoshka/polymode
multi-web-mode 116 kb 2013-08-23https://github.com/fgallina/multi-web-mode
mumamo 1153090 kb 2010-04-25http://ourcomments.org/Emacs/nXhtml/doc/nxhtml.html
multi-mode 123 kb 2009http://www.loveshack.ukfsn.org/emacs/multi-mode.el

(as of 2014-11-24)


polymode

Polymode is an emacs package that offers support for multiple major modes inside a single emacs buffer. It is lightweight, object oriented and was designed for very quick addition of new polymodes and extension/configuration of existing ones. It is based on a rigorous class hierarchy and makes multi-mode addition and extension a matter of several lines of code. It is also very fast because it is based on indirect buffers and doesn’t re-install the modes on chunk switching.

Polymode defines three major classes of multi-modes: polymodes with one predefined chunk mode (like noweb), polymodes with multiple predefined inner modes (like webmode) and modes with automatic inner modes which covers the case when type of the inner mode is not known in advance (examples are markdown and org-moe).

Polymode also provides highly configurable facilities for literate programming. Exporters, weavers and tanglers organically integrate into polymode system and are easy to create, configure and extend.

web-mode.el

Major mode for editing web templates: HTML files embedding parts (CSS / JavaScript) and blocks (server and client side). web-mode.el is autonomous and is compatible with many template engines : PHP, JSP, GSP (Grails), ASP / ASP.NET AJAX (Atlas), Django / Twig / Jinja(2) / ErlyDTL? (Zotonic) / Selmer, ERB, FreeMarker?, Velocity, Cheetah, Smarty, CTemplate / Mustache / Hapax / Handlebars / Meteor / Blaze /ember.js, Blade (laravel), Knockoutjs, Go Template (Revel), Razor/Play, Dust, Closure (soy), underscore.js, template-toolkit, Liquid (jekyll), angular.js, web2py, mako (pylons), reactjs (jsx), mojolicious.

Actively maintained by François-Xavier Bois.

mmm-mode.el

multi-web-mode.el

Auto select major mode for HTML files when point is moving around. Check updates at github. Written by FabianGallina. (Yes, it is actively maintained)

mumamo.el

MuMaMo (short for multiple major modes) needs Emacs 22 or later. It is distributed as part of nXhtml and can mix HTML+CSS+JavaScript, Java+HTML (JSP), PHP. It can also support NxmlMode (however this works best with Emacs 23).

You can search mumamo regions by major mode using Icicles.

multi-mode.el

Multi Mode is an implementation of the approach referred to in Emacs’ TODO. It probably only works in Emacs 21 and later.

- I have been using it with Emacs 23 with no issue. It also has 2009 in its copyright notice, so it seems like it is still being updated.

See also its uses in noweb.el and haskell-latex.el in the same directory.

Multi-mode is used by aspx-mode.el, which is a mode for editing ASPX files in emacs. aspx-mode handles HTML, browser Javascript blocks, CSS blocks, and C#, with proper highlighting and indenting, all in one buffer.

two-mode-mode.el

Two Mode Mode by DavidWelton?. This one is used for one of the solutions on the PhpMode page. It seems to be very easy to use. Just specify the start and end regular expressions for the second mode.

See EmacsLispAndLaTeX for an example.

Does two-mode-mode run on Emacs 23? I have tested it and it doesn’t change between modes.

I got it to work by changing the following:

    - (if (string= to-mode mode-name)
    + (if (string= to-mode major-mode)

Seems to need the following in emacs 24 since make-local hook has been removed:

    - (make-local-hook 'post-command-hook)
 

Indirect buffers

This is a built-in feature in Emacs. Indirect buffers feature does not exactly give multiple major modes in the same logical buffer but it gives user two (or more) different buffers which have their textual content linked together. To clone a buffer use ‘C-x 4 c’ and then use different major modes in the clones. See the Emacs reference manual for more information about indirect buffers. See also IndirectBuffers.

Library narrow-indirect.el facilitates creating indirect buffers cloned and narrowed from other buffers. And yes, you can use different major modes in them, even fontifying them differently etc. See NarrowIndirect.


Comments

What a shame that there are multiple multiple mode modes. As soon as you need mode X that requires multiple mode M1, while already using another mode which uses multiple mode M2, you’re loading far more than you need to. Just because TIMTOWTDI (sorry for the perl-ism) doesn’t mean you must do it more than one way.

It is worth mentioning the significant drawbacks of using indirect buffers to implement multi-mode editing in emacs. To make switching between indirect buffers look seamless, it is critical that all of the major modes share a single font face. Switching between modes with different faces or sizes is extremely jarring and unpleasant and causes the display to jump. Furthermore, using the keyboard to extend a selection across a mode boundary is currently not possible in polymode. As soon as the cursor moves into a new mode area, the indirect buffers are switched and the selection is lost. I personally find polymode to be nearly unusable, but short of giving up on emacs entirely, it is the only realistic option for editing Rmarkdown documents.


CategoryModes