mishoo / elisp-reader.el

Customizable reader for Emacs Lisp
72 stars 7 forks source link

Consider joining forces with emacs-cl? #1

Closed larsbrinkhoff closed 8 years ago

larsbrinkhoff commented 8 years ago

I have a complete Emacs Lisp implementation of the Common Lisp reader here: https://github.com/larsbrinkhoff/emacs-cl/blob/master/cl-reader.el

mishoo commented 8 years ago

That looks like an implementation of the CL reader in CL, not in Elisp. :-) Definitely nice to be able to write Emacs extensions in CL, but it's different than what I had in mind (which is merely the ability to enhance the Elisp reader from itself, instead of providing a different language).

I'm not sure how one project could benefit from the other.

larsbrinkhoff commented 8 years ago

It really is Emacs Lisp. Why do you think otherwise?

It's part of a CL implementation written in Emacs Lisp, so it uses code from other files. Maybe that makes it look strange.

mishoo commented 8 years ago

Yeah, I just noticed the IN-PACKAGE and other CL stuff so I speculated it isn't just Elisp in there.

I cloned the project and try to load load-cl, but I'm getting an error (void-variable EVERY) in cl-flow.el. (vanilla Emacs 24.5.1 here, Linux)

In any case, I was wondering how (if?) do you replace the Elisp reader, that is, say I get it loaded, can I then just load a file containing CL syntax with plain M-x load-library?

larsbrinkhoff commented 8 years ago

Sorry, it's not intensely maintained. I see the same error and will investigate.

It does not replace the Emacs Lisp reader. Rather, it adds a parallel Common Lisp environment alongside Emacs Lisp. So no, you would read and load CL syntax with separate functions.

I guess your reader accepts an extension of the Emacs Lisp syntax, e.i. it's backwards compatible? My reader by default doesn't cater to Emacs Lisp. But of course any CL reader can be extended to accept Emacs Lisp syntax.

mishoo commented 8 years ago

It does not replace the Emacs Lisp reader. Rather, it adds a parallel Common Lisp environment alongside Emacs Lisp. So no, you would read and load CL syntax with separate functions.

That makes sense actually, the languages are quite different and you don't want to ruin Emacs' ability to load Elisp code.

Yes, my reader just reads Elisp (and defers to the original C reader for some things it can't handle, like loading bytecode). And since it reads Elisp, it can (and does) replace the original read function by fset-ing it.

The thing it adds is that, being written in Elisp rather than C, it's extensible; so it adds a syntax for regexps, i.e. #/(foo|bar)/ produces "\\(foo\\|bar\\)", and a def-reader-syntax function which allows external code to define custom reader chars (sample usage).