diff --git a/docs/make.jl b/docs/make.jl index e0b9d1c0..a5dd1c6a 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -10,6 +10,7 @@ makedocs(; "config.md", "cookbook.md", "limitations.md", + "tricks.md", "debugging.md", "internals.md", "user_reference.md", diff --git a/docs/src/index.md b/docs/src/index.md index c915bfcf..3e7617c6 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -130,7 +130,7 @@ Revise is fairly ambitious: if all is working, subject to a few [Limitations](@r - any package that you load with `import` or `using` - any script you load with [`includet`](@ref) (see [Configuring the revise mode](@ref) for important default restrictions on `includet`) - any file defining `Base` julia itself (with `Revise.track(Base)`) -- any of Julia's standard libraries (with, e.g., `using Unicode; Revise.track(Unicode)`) +- any of Julia's standard libraries (with, e.g., `using Unicode; Revise.track(Unicode)`). Some stdlibs may require special handling; see, for example, a trick for modifying [REPL](@ref editREPL). - any file defining `Core.Compiler` (with `Revise.track(Core.Compiler)`) The last one requires that you clone Julia and build it yourself from source. diff --git a/docs/src/tricks.md b/docs/src/tricks.md new file mode 100644 index 00000000..fc37e895 --- /dev/null +++ b/docs/src/tricks.md @@ -0,0 +1,23 @@ +# Tricks + +## [Editing code that defines REPL](@id editREPL) + +Updating the code in Julia's REPL stdlib requires some extra trickery, because modified method definitions can't be deployed until you exit any currently-running REPL functions, like those handling the prompt that you're using to interact with Julia. A workaround is to create a sub-REPL that you can shut down, and then restart a new one whenever you want to test new code: + +``` +using Revise +using REPL +Revise.track(REPL) + +term = REPL.Terminals.TTYTerminal("dumb", stdin, stdout, stderr) +repl = REPL.LineEditREPL(term, true) +Revise.retry() + +while true + @info("Launching sub-REPL, use `^D` to reload, `exit()` to quit.") + REPL.run_repl(repl) + Revise.retry() +end +``` + +Many thanks to `staticfloat` for [contributing](https://github.com/timholy/Revise.jl/issues/741) this suggestion.