M-x all-things-emacs

Package Faves: js2-mode

April 4th, 2008 by Ryan McGeary · 7 Comments

I just played with Stevey’s new js2-mode. So many previous javascript modes for emacs just didn’t cut it, but now finally, I’m proud to see a javascript mode that works. Steve did a great job with this package. Kudos.

Installation

Grab the latest js2, put it in your load-path, and configure. Full instructions. Here’s my config:

(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
 
(setq js2-basic-offset 2)
(setq js2-use-font-lock-faces t)

(Steve, I’m one of those who like my font-lock settings, so thanks for keeping the font-lock-faces option around for us crazies.)

Features

  • Indenting that works! Finally.
  • Syntax highlighting that works. ‘Bout time.
  • Inline warnings and syntax errors. Useful.
  • Decent code folding. I like.
  • Other tidbits. You’ll have to read Steve’s long-winded post for more.

Tags: faves · javascript · reviews

7 responses so far ↓

  • 1 Soltys // Apr 5, 2008 at 11:06 am

    What font do you use?

  • 2 Ryan McGeary // Apr 5, 2008 at 6:07 pm

    Soltys, I use Monaco 12 on OS X:

    (create-fontset-from-fontset-spec
     (concat
      "-apple-monaco-medium-r-normal--12-*-*-*-*-*-fontset-monaco,"
      "ascii:-apple-monaco-medium-r-normal--12-100-*-*-m-100-mac-roman,"
      "latin-iso8859-1:-apple-monaco-medium-r-normal--12-100-*-*-m-100-mac-roman"))
     
    (setq default-frame-alist '((font . "fontset-monaco")))
  • 3 Josh // Apr 6, 2008 at 4:20 am

    Speaking of which, have you used http://emacs-app.sourceforge.net/ before? It seems like a much better mac citizen than carbon emacs.

  • 4 Ted // Apr 6, 2008 at 2:09 pm

    This new mode is great. I found a few subtle syntax problems as soon as I started using it.

  • 5 Ryan McGeary // Apr 6, 2008 at 10:27 pm

    Josh, Yes, I’ve tried Emacs.app. I didn’t much care for it. Emacs is the one application I don’t want to behave like a Mac citizen, yet I found Emacs.app to be both a poor Mac citizen and a poor Emacs citizen. It’s been a long while, and you peeked my interest so I tried Emacs.app again. Unfortunately, I found the out-of-box experience to be as poor as I remember. I’m afraid I’ll have to stick with Carbon Emacs. What about Emacs.app do you particular like? As far as Mac citizenship goes, Aquamacs is probably the winner in my eyes.

    Ted, Please be sure to submit those syntax problems to Steve.

  • 6 Will Farrington // Apr 8, 2008 at 3:52 am

    What color theme are you using? =)

  • 7 Ryan McGeary // Apr 8, 2008 at 4:03 am

    Will, color-theme-arjen:

    (require 'color-theme)
    (color-theme-initialize)
    (color-theme-arjen)

Leave a Comment