elisp.js/README
Sami Samhuri 77f1a9eb93 [NEW] if, negative numbers, regex type & literal, more...
Sorry for the massive commit. I'll try not to do this.

Several new features:

 * Proper conses and lists (probably slow, can optimize later)
 * Parse negative numbers
 * Regular expressions (piggyback off js regex, not emacs compatible)
 * string-match and symbol-name primitives
 * if special form
 * car, cdr, cadr, caddr, cadddr, nth, nthcdr, map, length, null,
   symbolp, listp, stringp, numberp, etc. only in JS now but I will
   expose them in lisp as primitives soon.

Fixed:

 * setq now silently defines undefined variables

some miscellaneous things:

 * simple init system to specify init code that loads after all defs
   have been read
 * String.camelize function stolen from Prototype
2009-12-06 20:50:46 -08:00

89 lines
2.7 KiB
Text

Emacs Lisp implementation in JavaScript.
Copyright (c) 2009 Sami Samhuri - sami.samhuri@gmail.com
Released under the terms of the MIT license. See the included file
LICENSE.
Latest version available on github:
http://github.com/samsonjs/elisp.js
Introduction
(or "You must be kidding")
==========================
I'm not 100% sure why I think this might be useful to somebody. The
idea of editing code directly on github or bitbucket in a web browser
is pretty cool though, and if you're going to do such a thing why not
use the best tools available. IMO those tools are written in Emacs
Lisp so I would like to use them in the browser. Maybe with some
HTML5 offline goodness thrown in.
Seeing Ymacs[1] in action[2] was also an inspiration to start this
project as I've had it on my TODO list for several months now. Emacs
in the browser could be a reality; Ymacs is proof.
[1] http://www.ymacs.org/
[2] http://www.ymacs.org/demo/
Getting Started
===============
I use Emacs and js-comint.el[3] with inferior-js set to
/opt/local/bin/js, which is SpiderMonkey[4] from MacPorts[5] on Snow
Leopard. C-c b sends the buffer to the JS repl and then I use the
EL.rep (read-eval-print), EL.repl, EL.parse, EL.eval, and EL.print
functions defined in the section titled Lisp Support near the end of
el.js.
[3] http://js-comint-el.sourceforge.net/
[4] http://www.mozilla.org/js/spidermonkey/
[5] http://www.macports.org/
Running js under rlwrap and then using load('el.js') works just as
well if you don't use Emacs but still want readline. Type EL.repl()
to start the REPL or evaluate one thing with EL.rep,
e.g. El.rep("(* 4 3)")
There are other interfaces into the parser and evaluator besides the
shortcuts. new EL.Parser([input]) returns a parser object and likewise
new EL.Evaluator([exprs]) returns an evaluator object.
Mainly toy functions that do extremely simple operations on numbers
and strings can be implemented right now. Stay tuned, or better yet
hack away and submit a pull request on github[6].
[6] http://github.com/samsonjs/elisp.js
What's here?
============
Not much compared to the real thing but it's a decent start for < 1000
lines.
* parser
(ints, floats, strings, symbols, lists, quoted expressions)
* symbol table
(functions & variables separate)
* (broken) lexical scoping
* expression evaluator
* simple tagged primitive types
(string, symbol, primitive, function, number)
* special forms for defvar, defun, set, setq, and quote
* eval/apply for atoms, function calls, and a few special forms
* a few primitive math ops
(thanks to JS' overloading + works on strings too)
* 2 horrible print functions
(JS "pretty" printer & a half-assed Lisp print)