-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
add REPL hooks #2
Comments
Revise has a similar use case where it wants to patch the REPL to revise methods upon each evaluation in the REPL. The code on how it manages to do that (https://github.com/timholy/Revise.jl/blob/382e872375de76f279556d076730a0fe5de4520f/src/Revise.jl#L743-L842) is likely useful. The question now is of course, what happens when there are two REPL thieves in play at the same time... Perhaps we need a REPLThieves.jl package ;). cc @timholy. |
Yup, it looks like I did it exactly the same way as Revise does and doing it twice won't play nicely. It might well be possible to intercept the eval call in a slightly different way that does play nicely though. I can try to take a look at some point in the next few days... |
FWIW a while ago I wrote a small package to easily work with hooks for this sort of thing: https://github.com/ssfrr/Hooks.jl I never ended up registering it but this is the sort of problem it's designed to solve so it might be worth revisiting. It's also possible we could add a set of |
Basically we need someone to create a REPLHooks package that allows you to add hooks to the REPL, then refactor Revise to use it, at which point SoftGlobalScope can use it too. |
Note that Julia 1.5 now does this for us, and adds a general mechanism for REPL hooks (JuliaLang/julia#34626). |
As suggested by @dawbarton, in JuliaLang/julia#28789 (comment), it is possible to hack the active REPL to use SoftGlobalScope. Would be nice to add this feature here, so that
using SoftGlobalScope
patches the active REPL if there is one.Similar to this code in OhMyREPL.jl, we would do this in
__init__
only in interactive mode.@KristofferC, your advice on the cleanest way to patch the REPL's
eval
loop would be appreciated.The text was updated successfully, but these errors were encountered: