MasonProtter / ReplMaker.jl

Simple API for building repl modes in Julia
Other
134 stars 14 forks source link

Fix startup script example in README.md #37

Closed GHTaarn closed 6 months ago

GHTaarn commented 1 year ago

The example startup script was not legal Julia code, this is my suggested fix

GHTaarn commented 1 year ago

After testing this on Julia 1.8.5 I found that it also does not work as it throws a MethodError. The best solution that I could find that actually works is:

import ReplMaker

atreplinit() do repl
    try
        @async try
            ReplMaker.initrepl(
                apropos;
                prompt_text="search> ",
                prompt_color=:magenta,
                start_key=')',
                mode_name="search_mode"
            )
        catch e1
            @warn e1
        end
    catch e2
        @warn e2
    end
end
GHTaarn commented 1 year ago

Is @async really necessary? I found that it worked fine with just the following startup.jl:

import ReplMaker

atreplinit() do repl
    try
        ReplMaker.initrepl(
            apropos;
            prompt_text="search> ",
            prompt_color=:magenta,
            start_key=')',
            mode_name="search_mode"
        )
    catch e1
        @warn e1
    end
end
MasonProtter commented 6 months ago

Oops, thanks. The @async block is not necessary, but nice because it can get you into the REPL quicker if the startup takes a while.