M-x all-things-emacs

Package Faves: js2-mode

April 4th, 2008 by Ryan McGeary · 9 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.

Tags: faves · javascript · reviews

9 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)
  • 8 Steve Yegge // Jun 5, 2008 at 11:45 am

    Hey man, glad you like the mode!

    I’ve only made minor bug fixes and tweaks for the past month or so, but today I started on a major overhaul, prompted by a growing bug backlog and also getting some mileage using the mode myself. I’ve been working with the mumamo.el guy to figure out a way to make them work together, and I think we’ve got a solution. Hopefully I can post a big update in the next few weeks.

    FWIW, the FSF has offered to bundle it with the next version of Emacs. I’ve signed the paperwork and assigned them the copyright, etc. Neat.

    I also use Carbon Emacs and Monaco 12 point (antialiased, of course). Love it!

    Cheers,

    -steve

  • 9 leson // May 16, 2009 at 12:36 pm

    What picture remark tool are you using? _