People say that emacs is the most extendable editor in the world; however, I didn’t really understand how powerful it is until one of it extension Swank.js blowed my mind. Take a look at this awesome screen cast produced by emacs rocks.
Awesome, is it? However, installing
swank.js is really nontrivial. As a result, I want to share my note on setting up
swank.js on my machine.
- Mac OSX 10.8
- Emacs 24.3
- package manager: homebrew
- C compiler: Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn) Target: x86_64-apple-darwin12.3.0
My Emacs is installed via homebrew.
Setting up emacs ecosystem. In
1 2 3 4 5 6
Remember to evaluate the buffer
1 2 3
slime (lisp-emacs protocol)
1 2 3
1 2 3 4
swank.js dependencies in emacs:
M-x package-install exec-path-from-shell M-x package-install js2-mode M-x package-install slime M-x package-install slime-js M-x package-isntall js2-refactor M-x package-install ac-slime
Final configurations in
1 2 3 4 5 6 7 8
First, you need a real server running at port 3000. You can do that either using
python -m SimpleHTTPServer 3000 or other server programs like Ruby on Rails. You can change the default port setting by overwritten the variable
slime-js-target-url in your
Next, use the command
M-x slime-js-jack-in-browser in emacs. It should open up Chrome in your workspace. However, my Chrome browser didn’t work well with
swank-js; an alternative solution is to open
localhost:8009 in safari. It worked for me anyway. Now, you should see that emacs shows a prompt like this:
; SLIME 2013-03-12 Remote attached: (browser) Safari6.0 NODE>
alert("hello world!") and press enter. You should see your browser pop up an alert window with hello world, and that’s it! You’ve successfully installed
Wow, it’s really complicated. I can’t remember it unless I write it down.