Skip to content

Commit

Permalink
Add docs on trick for handling REPL
Browse files Browse the repository at this point in the history
Closes #741
  • Loading branch information
timholy committed Sep 26, 2024
1 parent c2fd7a4 commit a2c8d87
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ makedocs(;
"config.md",
"cookbook.md",
"limitations.md",
"tricks.md",
"debugging.md",
"internals.md",
"user_reference.md",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions docs/src/tricks.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit a2c8d87

Please sign in to comment.