CoffeeScript

From WikEmacs
Revision as of 10:54, 8 April 2014 by Elvince (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

CoffeeScript is a little language that compiles to JavaScript.

Coffee mode[edit]

There is a major mode to edit Coffee and it is available in ELPA: coffee-mode. Its installation is then straightforward: M-x package-install RET coffee-mode RET.

See its documentation: https://github.com/defunkt/coffee-mode/

Flymake[edit]

A flymake handler for syntax-checking Coffeescript source code using coffeelint or coffee: https://github.com/purcell/flymake-coffee

Tips and tricks[edit]

Convert snippet from JavaScript to Coffee[edit]

Coffee-mode comes with a nice function which is not documented. If you copy a JS snippet from the web you'll want to convert it to coffee. While there are online tools, you can do the following:

  • install `js2coffee` with `npm`:
   npm install -g js2coffee  # npm comes with nodejs
  • now select a region and call M-x coffee-js2coffee-replace-region