-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Make the REPL re-entrant and easier to debug #6413
Conversation
cc: @loladiro |
LGTM in general, but see Travis failure. |
Oops. I've made the |
@@ -39,6 +39,9 @@ type Prompt <: TextInterface | |||
hist | |||
end | |||
|
|||
string(x::Prompt) = string("Prompt(\"", x.prompt, "\",...)") | |||
show(io::IO, x::Prompt) = print(io, string(x)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it suffices to define print
and you get both of these automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right, the string method definition is superfluous. The chain goes string
-> print
-> show
.
Prevent a recursive show call with Prompt objects
Previously, the keymap functions were assigned a name with the eval macro (in global scope). This changes the keymap macro to instead return an anonymous function so that additional instances of the REPL don't clobber the keymap functions of previous ones.
I've removed the superfluous |
Make the REPL re-entrant and easier to debug
The two patches here simplify working with the REPL itself. The first allows for printing of REPL objects in the REPL. The second makes it re-entrant.
Previously, the keymap functions were assigned a name with the eval macro (that is - in global scope). This changes the keymap macro to instead return an anonymous function so that additional instances of the REPL don't clobber the previous keymap functions.
So, you can now start a second REPL inside the first. I've found this particularly useful for testing keybindings, but I could see it being useful in other cases, too.
Base.REPL.run_repl(Base.REPL.LineEditREPL(Base.Terminals.TTYTerminal(get(ENV,"TERM",""),STDIN,STDOUT,STDERR)))
cc: @nolta @loladiro