-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjulia_repl.jl
More file actions
37 lines (32 loc) · 1.08 KB
/
Copy pathjulia_repl.jl
File metadata and controls
37 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using REPL
using REPL: LineEdit
# Register keybind '.' in Julia REPL:
function init_repl_if_not(; _init_repl=init_repl)
active_repl = try
Base.active_repl
catch err
err isa UndefVarError || rethrow()
return
end
if isinteractive() && typeof(active_repl) != REPL.BasicREPL
_init_repl(active_repl)
end
end
# See: https://github.com/JuliaInterop/RCall.jl/blob/master/src/setup.jl
function init_repl(repl)
start = function(s, _...)
if isempty(s) || position(LineEdit.buffer(s)) == 0
# Force current_module() inside IPython to be Main:
Base.eval(Main, :($start_ipython()))
println()
LineEdit.refresh_line(s)
else
LineEdit.edit_insert(s, '.')
end
end
ipy_prompt_keymap = Dict{Any,Any}('.' => start)
main_mode = repl.interface.modes[1]
main_mode.keymap_dict = LineEdit.keymap_merge(main_mode.keymap_dict,
ipy_prompt_keymap)
end
# See: https://github.com/JuliaInterop/RCall.jl/blob/master/src/RPrompt.jl