Closed samhedin closed 3 years ago
julia-snail-send-line
is not module-context aware. I did that for simplicity of implementation. It just copies the line right into the Julia REPL without applying any of Snail’s module-awareness magic. (The Julia REPL has no special module handling.)
For your purposes, try using julia-snail-send-region
. You’ll have to have an active region for it to work (with transient-mark mode enabled, which is the default). Default keybinding C-c C-r
. Be aware though, that in your example, x
will be bound in the Hello
module, so to access it from the REPL, you’ll still have to type Hello.x
. This is a limitation of the Julia REPL itself, and until (and unless) there’s an Elisp implementation of the Julia REPL in Snail, there is no help for it.
Gotcha! That makes sense, and it should be fine to just write a command that marks the current line and uses send-region. Something like
(defun julia-snail-send-line-as-region ()
(interactive)
(save-excursion
(move-beginning-of-line 1)
(push-mark-command t)
(move-end-of-line 1)
(julia-snail-send-region)))
However, when I mark and send a region I get UndefVarError: JuliaSnail not defined
Very strange. Without the JuliaSnail
module available on the Julia side, nothing should work. Let's try to get to the bottom of it.
Start a fresh session with Snail (i.e., kill all existing REPLs, etc.). Open a Julia source file you want to work with. Run julia-snail
. That should pop up a Julia REPL vterm buffer. That buffer should then say JuliaSnail.start(10011);
, which starts the network server listening to messages from the Emacs side. It might take a little while to get going (thanks to the good old "time to first plot" problem).
Now, try to reproduce the problem that produced the JuliaSnail not defined
error.
You should have a *julia* process
buffer. Please paste or attach its contents to this ticket.
Run versioninfo()
in your REPL and paste the output.
Finally, run Base.load_path()
in your REPL and paste the output.
Very strange. Without the
JuliaSnail
module available on the Julia side, nothing should work. Let's try to get to the bottom of it.Start a fresh session with Snail (i.e., kill all existing REPLs, etc.). Open a Julia source file you want to work with. Run
julia-snail
. That should pop up a Julia REPL vterm buffer. That buffer should then sayJuliaSnail.start(10011);
, which starts the network server listening to messages from the Emacs side. It might take a little while to get going (thanks to the good old "time to first plot" problem).Now, try to reproduce the problem that produced the
JuliaSnail not defined
error.You should have a
*julia* process
buffer. Please paste or attach its contents to this ticket.(ns = [:Main], reqid = "e1c0db3c", code = "normpath(joinpath(VERSION <= v\"0.7-\" ? JULIA_HOME : Sys.BINDIR, Base.DATAR...) (julia-snail--response-success "e1c0db3c" "/nix/store/lw11hzksckahr69r6p4jx4fpq3ahpwdi-julia-1.5.4/share/julia/base") (ns = [:Main], reqid = "f2796b0b", code = "Pkg.activate(\"/home/sam/git/testjl/Hello/\")") (julia-snail--response-success "f2796b0b" nil) (ns = [:Main], reqid = "0606dd94", code = "JuliaSnail.CST.moduleat(\"bW9kdWxlIEhlbGxvCnkgPSAzCnRlc3RtZSgpID0gMwoKI2RvZX...) (julia-snail--response-success "0606dd94" (list)) (ns = [:Main], reqid = "9f362163", code = "include(\"/tmp/julia-tmpxHa1Ba\"); JuliaSnail.elexpr(true)") (julia-snail--response-success "9f362163" "t") (ns = [:Main], reqid = "209317a9", code = "JuliaSnail.CST.moduleat(\"bW9kdWxlIEhlbGxvCnkgPSAzCnRlc3RtZSgpID0gMwoKI2RvZX...) (julia-snail--response-success "209317a9" (list "Hello")) (ns = [:Hello], reqid = "c60c3eb0", code = "include(\"/tmp/julia-tmpS7zVkf\"); JuliaSnail.elexpr(true)") (julia-snail--response-failure "c60c3eb0" "UndefVarError: JuliaSnail not defined" '("top-level scope at none:1" "eval at boot.jl:347 [inlined]" "eval_in_module(::Array{Symbol,1}, ::Expr) at JuliaSnail.jl:138" "macro expansion at JuliaSnail.jl:541 [inlined]" "(::Main.JuliaSnail.var\"#33#38\"{Sockets.TCPSocket})() at task.jl:356"))
> Run `versioninfo()` in your REPL and paste the output.
Julia Version 1.5.4 Commit 69fcb5745b* (2021-03-11 19:13 UTC) Platform Info: OS: Linux (x86_64-unknown-linux-gnu) CPU: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-9.0.1 (ORCJIT, skylake) Environment: JULIA_ERROR_COLOR = red
> Finally, run `Base.load_path()` in your REPL and paste the output.
julia> Base.load_path() 4-element Array{String,1}: "/home/sam/git/testjl/Hello/Project.toml" "/home/sam/.julia/environments/v1.5/Project.toml" "/nix/store/lw11hzksckahr69r6p4jx4fpq3ahpwdi-julia-1.5.4/share/julia/stdlib/v1.5" "/home/sam/.emacs.d/.local/straight/repos/julia-snail/Project.toml"
Is that informative? I see now that this only happens when I'm working in a package. If I use a plain `.jl` file, everything appears to work.
Thanks for sending the details! That’s a bug, guess I didn’t test that use case thoroughly enough. :) Fixed in https://github.com/gcv/julia-snail/commit/03b4296ba7151963eb3c850f3314b02644101f51
Since you use Straight, just pull the latest master and reload Snail. Maybe restart Emacs just to be on the safe side.
Great to see another Nix + Emacs + Julia user in the wild. Those are my favorite three computing tools right now.
Thanks for sending the details! That’s a bug, guess I didn’t test that use case thoroughly enough. :) Fixed in 03b4296 Since you use Straight, just pull the latest master and reload Snail. Maybe restart Emacs just to be on the safe side.
Yepp, that did it. Thanks!
Great to see another Nix + Emacs + Julia user in the wild. Those are my favorite three computing tools right now.
Same, I'm super happy that Julia saved me from python/matlab and Emacs from in-browser notebooks.
Thanks for this very promising package! It seems like this has potential to make julia development in emacs top notch. I have an issue though, which I can reproduce this way:
Now in emacs I open
testql/Hello/src/Hello.jl
.julia-snail-mode
is enabled and I runjulia-snail
.julia-snail-package-activate
, select project dirtestjl/Hello
Julia> Activating environment at .../testjl/Hello/Project.toml
Finally I runjulia-snail-send-buffer-file
here:Now, it seems like I should be able to hover over the x and run
julia-snail-send-line
, but that gives the errorHowever, the same but with
x = Hello.testme()
in the buffer works. If I try to sendtestme()
into the REPL, I getUndefVarError: JuliaSnail not defined
. Is there a step that I've missed? It's so close to working as I'd expect.