p3r7 / norns.el

monome norns interactive development for Emacs
MIT License
9 stars 2 forks source link

Comments confuse Maiden when sending code #2

Open xmacex opened 2 weeks ago

xmacex commented 2 weeks ago

First of all, this thing is so cool, thank you for making it ✨

When sending code with C-c ! r or similar, if the code has comments, Maiden gets confused. My guess is that EOLs are somehow lost in transit, so a -- doesn't get terminated.

This is confusing, and also can leave Maiden in a quasi-unresponsive states waiting for sufficient number of terminting ends to close off what has been started before the comment which never ended. Lua isn't particularly forgiving or clear about it's error messages, is it.

A side-effect for human behavior is that code commenting practices are disencouraged :(

Suggestion for change

Direction 1. Secure EOLs

Making sure to secure that EOLs arrive for Maiden itself to be able to terminate the comment, and read the next line as code. Might depend on EOL character, and now that I write this I realize I have not tried with Windows style EOLs. I would guess Lua sets a standard for EOLs, maybe following the UNIX style. Does the web socket transport layer mess with them?

Direction 2. Filter out comments

Filter comments with something like (replace-regexp-in-string "--.*$" "" cmd) before sending cmd over. It should be a non-greedy regexp, since code can have a multiple comments, with executable code in between. An edge case is a double (or more) dash appears inside a string, in which case it should pass.

Can Maiden in some circumstances interpret comments, and they should be passed? I figure the basic idea of comments is that computers ignore them, but maybe there is a chance that a computer can read them too? An example would be being docstrings. Does it matter for norns programmers?

Direction x

🧭

I have not looked at how the SuperCollider side behaves.

p3r7 commented 2 weeks ago

so, mhm, so currently we replace carraige returns w/ ; to send everything on a single line.

but idk if it's really necessary... i wonder how the maiden web interface handles this...

if it is direction 2 would solve it (except super special edge case of a string containing "--" which is kinda niche).

i'd love a PR if you get it to work.