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

Package cannot be loaded in atreplinit with startup.jl or on the REPL #55

Open
caleb-allen opened this issue May 29, 2023 · 0 comments
Open
Labels
design There may not be a correct answer

Comments

@caleb-allen
Copy link
Owner

So far, the standard way to load VimBindings.jl has been to do the following.

$ julia -i -e "using VimBindings"

One reason for this is that the package overwrites a large amount of REPL code, and since the REPL is initialized and then atreplinit() is called, any code overwritten is simply discarded since the world age of the VimBindings.jl code is younger than the REPL code running in a loop. More details here

This is also why a REPL user cannot simply call using VimBindings from within the REPL to "gain" new behavior.

In the course of writing this issue, I discovered that VimBindings can in fact be loaded from startup.jl—only it must be loaded outside of atreplinit, for example:

if isinteractive()
    @eval using VimBindings
end

Looking at client.jl in julia/base, it becomes clear why this is the case: REPL code is loaded, and immediately atreplinit is called (as the name suggests). Thus, trying to initialize VimBindings from within atreplinit won't affect any REPL code, because it's already been initialized.

It is blindingly obvious in hindsight that REPL code can be overwritten and modified before a call to atreplinit! But it is what it is.

Still, it may be able to be improved. The best approach would be one which can simply take the repl object and modify the object itself, rather than overwriting any stdlib code at all.

@caleb-allen caleb-allen added the design There may not be a correct answer label May 29, 2023
@caleb-allen caleb-allen changed the title Package cannot be loaded in atreplinit with startup.jl Package cannot be loaded in atreplinit with startup.jl or on the REPL May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design There may not be a correct answer
Projects
None yet
Development

No branches or pull requests

1 participant