generic-x.el (which comes with Emacs)
doesn’t handle indentation well, and fails to correctly
highlight C-style (
/* … */) comments. But
it’s fine for short-term use: since it ships with Emacs,
it’s already there when you need it.
To enable it, add
(require 'generic-x) to
~/.emacs. This will automatically
associate files with
.js extensions with
My recommendation: Karl Landström’s
indentation well, and both C- and C++-style (
…) comments. A winner! To use, place
load-path and add the following to your
There’s also ecmascript-mode.el,
which is a derived mode from
doesn’t appear to do anything that
regardless of your personal settings. Thanks to krupan and
Mathias for the link.
In addition to all of the above, there’s the
with XEmacs, which I’m told works in Emacs as well
(and is even bundled with Aquamacs). Thanks to Reed and Xah for
Robustness tip: simple failover
Say you’ve installed
machine B. Ideally, your
file should detect if
should use it, but if it isn’t, it should fall back on
generic-x.el. This is pretty easy stuff.
generic-x as above.
Then check for the presence of
This way, you can copy your
~/.emacs file to some other machine, and
you know it won’t break.