REPL: allow editing current input in editor (via Meta-e) #33759
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The REPL editing features are decent, but as the multi-line input grows, it can be convenient to quicly jump to your favorite editor... let's make this feature available trough Meta-e.
In the current state, we open a temporary file with the REPL's current input, call
edit()
on this file, and then load the REPL input buffer with its new content. If the file has been modified, we execute directly the code, otherwise we assume that the user changed her mind and we restore the input buffer as it was before the call toedit()
. Suggestions welcome for this particular behavior (*).It's easy to try this feature out without having to recompile Julia, by putting the three new functions in your startup.jl file, together with
And adding the keybinding, e.g.
(*) This is currently implemented with a call to
ctime
, but might be more safe by comparing the content of the buffers before/after. For some reason, there is a little bug: if the first time the feature is used, the file is not updated, the input is still executed; but this doesn't happen when I put the new functions in my startup.jl file and run master (as described above).