murarth / ketos

Lisp dialect scripting and extension language for Rust programs
Apache License 2.0
751 stars 45 forks source link

About sexp by sexp multi line editing #39

Closed xieyuheng closed 6 years ago

xieyuheng commented 6 years ago

I saw ketos' repl handles sexp across multi lines in the following way ::

ketos=> (+ 1 2
ketos(> 3
ketos(> (+ 4 5
ketos(> )
ketos(> )
15
ketos=>

Is it possible to use linefeed to support sexp by sexp multi line editing ? (like the repl of chez-scheme)

(see also https://github.com/kkawakam/rustyline/issues/153)

murarth commented 6 years ago

I want to make sure I'm understanding correctly. What I think you're proposing is this:

Is this accurate?

xieyuheng commented 6 years ago

yes! for lisp sexp and string literal only.

xieyuheng commented 6 years ago

Maybe readline-like crate (like linefeed) is appropriate for this feature, and we need a crate like read-sexp for this ?

xieyuheng commented 6 years ago

If this feature is ready, it will simplify the read-sexp part of a repl.

xieyuheng commented 6 years ago

I have a little repl now :: https://github.com/xieyuheng/jojo/blob/master/src/repl.rs enjoy using linefeed :)

It would be great if linefeed can support the read-sexp feature, but we can live without it :P

feel free to close this issue anytime.

murarth commented 6 years ago

It would be outside the scope of linefeed to support this, but ketos could support this by overriding the command that executes when the user presses Enter.

I'll see what I can do.

xieyuheng commented 6 years ago

GREAT!

I wish I could learn from you about how to achieve this !

murarth commented 6 years ago

I've just pushed a commit that implements this feature.

Let me know if it works as expected or if you find any bugs.

xieyuheng commented 6 years ago

Thanks for doing this. It helped alot. I am closing this for now ~