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

implement pre-run REPL hooks. #16384

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,9 @@ function run_frontend(repl::LineEditREPL, backend)
interface = repl.interface
end
repl.backendref = backend
if length(Base.pre_run_repl_hooks) > 0
Base._atreplrun(repl)
end
run_interface(repl.t, interface)
dopushdisplay && popdisplay(d)
end
Expand Down
16 changes: 16 additions & 0 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,22 @@ function _atreplinit(repl)
end
end

const pre_run_repl_hooks = []

atreplrun(f::Function) = (unshift!(pre_run_repl_hooks, f); nothing)

function _atreplrun(repl)
for f in pre_run_repl_hooks
try
f(repl)
catch err
show(STDERR, err)
println(STDERR)
end
end
end


function _start()
empty!(ARGS)
append!(ARGS, Core.ARGS)
Expand Down