Emacs JS2 Mode Indentation Fix

emacs javascript

2010-10-21 03:00:46 +0000

If you use Emacs to code (and manage files, edit images, and browse the web), you are probably aware of the multitude of javascript modes available.

If not, then when you read about programming javascript in Emacs you’ll see references to js-mode, js2-mode, espresso-mode, and more.

The good news is, js-mode and espresso-mode are the same, because espresso mode was integrated into emacs proper and renamed js-mode.

If you want a more rich mode to edit javascript, you might have stumbled upon js2-mode. js2-mode is different from other progamming modes in that it actually parses javascript to do its work. It knows the javascript language waaaaay better than any collection of regex could.

The problem is, js2-mode has some, uhm, how shall we say, poor choices when it comes to indentation. You can read about the problem and one possible solution (which does work) here.

Another option I found is a fork of js2-mode that incorporates the indentation fixes as well as other improvements to js2-mode.

Check it out, you’ll be happy you did.

blog comments powered by Disqus