Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: adding an edit command #77

Open
jwoertink opened this issue Dec 4, 2017 · 5 comments
Open

Feature: adding an edit command #77

jwoertink opened this issue Dec 4, 2017 · 5 comments

Comments

@jwoertink
Copy link
Collaborator

Pulling this in from #75 (comment)

@veelenga wrote :

edit command may be a nice addition now. It could allow user to edit the file in vim or something like that. @greyblake @jwoertink WDYT ?

@jwoertink
Copy link
Collaborator Author

I like the idea. It could pull from $EDITOR (or vim by default 😏 ), but wouldn't that basically be what the paste command does now?

@veelenga
Copy link
Member

veelenga commented Dec 4, 2017

Not really. Paste inserts new content into the file (and icr executes it then). Edit will give you a way to edit that file. So it will be possible to remove previously inserted "bad commands". But, i don't know, that may an overhead....

@jwoertink
Copy link
Collaborator Author

So that file could look something like

X = 1
class Test
end

def __icr_exec__
  puts 1 + 1
  puts X
end

puts "|||YIH22hSkVQN|||\def __icr_exec__...."

This edit would probably need a way to denote what can't be removed. Maybe a comment appended to the end of those lines?

Then again, now that I think about it. Would people want this as a feature vs just opening up a file and throwing some test code in that, then running it? If you're just talking about un-doing a bad command, that may go along with my initial commit I started for adding ctrl-C functionality. My thought there was like with irb, you can open a class or a method, then start defining stuff. If you mess up, you just hit ^C and wipe that out. I find myself typing "edn" a lot lol.

@veelenga
Copy link
Member

veelenga commented Dec 5, 2017

Right, this is what I'm afraid of as well. If we give a way to the users a direct way to edit the file, anyone can accidentally break a hole session while removing def __icr_exec__ line or a delimiter. I agree, this is dangerous and unwanted functionality.

I regularly use vicr for multi-line content, but sometimes just need to execute one line of code to test something, and icr is faster for this. So that's why i see some mixed approach (repl & editor) helpful.

Probably Ctrl-C will help. I have never used irb that way and should give it a try :)

@jwoertink
Copy link
Collaborator Author

Oh nice. I hadn't seen vicr until now. A mixed approach would be nice. Maybe we take this whole thing back to the drawing board, and look at icr from the ground up? Crystal has come a long way since the icr inception, so maybe there's new stuff we can take advantage of?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants