qvqhkg
3.429K
· August 2012 ·
Df8f7177a8b94e525e7ee6e2693f62fa

LiveCode Node.JS Apps

Why should those geeky clojure and lisp types get to have all the fun?

Using js-comint and node you can easily livecode your node code, sending one expression or region at a time to be executed in an Emacs REPL.

For the TLDR, check out http://twitter.com/emacs/status/13134393723 and fix the node command, but it's pretty simple:

First, Install js-comint. Using el-get it's as simple as

el-get-install js-comint</code></pre>

Then, instead of the code in that tweet, add the following to your emacs init file:



(require 'js-comint)
(setq inferior-js-program-command "node") ;; not "node-repl"
;; Use your favorited js mode here:
(add-hook 'js3-mode-hook '(lambda ()
(local-set-key "\C-x\C-e"
'js-send-last-sexp)
(local-set-key "\C-\M-x"
'js-send-last-sexp-and-go)
(local-set-key "\C-cb"
'js-send-buffer)
(local-set-key "\C-c\C-b"
'js-send-buffer-and-go)
(local-set-key "\C-cl"
'js-load-file-and-go)
))
</code>
</pre>
</p>

You don't have to, but you can manually start the REPL with M-x run-js

Then you're set. Just open a node file and start coding. As you go, you can send code to the REPL and see how it works.

This is especially useful for working with APIs, less-than-well-documented plugins and other black boxes where you need to poke around a bit to figure out how things work.

Sign in or sign up to add your response.