KristofferC / OhMyREPL.jl

Syntax highlighting and other enhancements for the Julia REPL
https://kristofferc.github.io/OhMyREPL.jl/latest/
Other
768 stars 60 forks source link

Ctrl R to search and --load option when launching Julia #271

Closed PGS62 closed 2 years ago

PGS62 commented 2 years ago

I find that I can't get Ctrl+R (search REPL history) to work if I launch Julia with the --load option.

More details: OhMyREPL is installed as recommended and Ctrl+R works nicely as soon as Julia launches. But if I launch Julia with the --load option then Ctrl R does not launch OhMyREPL's nifty search but instead Julia's built in search. That's true even if the file loaded is empty, and my efforts to amend the loaded file to coax OhMyREPL to work came to naught.

julia> versioninfo()
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 8
  JULIA_PKG_DEVDIR = C:/Projects
Moelf commented 2 years ago

how is it different from -i? when you --load a file is Julia even considered interactive?

PGS62 commented 2 years ago

I just tested, if one launches Julia with the --load option then isinteractive() does return true.

I imagine it's unusual to launch Julia with the --load option set and also to wish for interactive behaviour. I wish to do it in relation to code I have to implement interop between Julia and Microsoft Excel. https://github.com/PGS62/JuliaExcel.jl

KristofferC commented 2 years ago

Maybe it has to do with https://github.com/KristofferC/OhMyREPL.jl/blob/aa1d7e258f788dfb261ad070fb39657e9c9ab98a/src/OhMyREPL.jl#L91-L93. Probably the commands bit.

PGS62 commented 2 years ago

@KristofferC - thanks for pointing me to those lines. In my test (julia --load empty_text_file.jl) options.isinteractive has value 0 when line 91 executes and options.commands has a value different from C_NULL. Commenting out line 92 seems to makes Ctrl+R work as I'd like it to when Julia's launched with the --load option.

Would removing lines 91 to 93 be a possibility, or might that cause all sorts of other problems in different use-cases?

KristofferC commented 2 years ago

Can't you run with julia --load empty_text_file.jl -i?

PGS62 commented 2 years ago

Ah, yes that does work. Thanks!