Skip to content

Instantly share code, notes, and snippets.

@uraraurara
Created October 5, 2012 16:03
Show Gist options
  • Save uraraurara/3840718 to your computer and use it in GitHub Desktop.
Save uraraurara/3840718 to your computer and use it in GitHub Desktop.
javascript environment in emacs with node
;; http://stackoverflow.com/questions/6605058/what-are-these-shell-escape-characters
;; the following assumption:
;; * using nodebrew
;; * major version of emacs is above 24
;; ----
;; A. Do package-install js-comint
;; B. Create shell file `node2' at ~/.nodebrew/current/bin/node2 and chmod +x node2
#!/bin/sh
env NODE_NO_READLINE=1 node $@
;; C. Add the following code in .emacs.d/init.el
;; js-comint
(require 'js-comint)
(setq inferior-js-program-command "node2")
(add-hook 'js2-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)
(local-set-key "\C-c\C-r" 'js-send-region)
))
;; try to boot emacs and M-x run-js command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment