gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
233 stars 23 forks source link

Can you access the result of evaluation in the REPL? #158

Open danielmatz opened 1 month ago

danielmatz commented 1 month ago

After I call julia-snail-send-dwim, I sometimes want to play around with the resulting object in the REPL. It seems like that currently isn't possible. Is that right?

Is that something that could be added? Conceptually, it's a bit like the ans variable. I suppose one option is actually to bind ans to the result of the last evaluation. Or maybe there's a special JuliaSnail.result global that gets updated on each evaluation?

gcv commented 1 month ago

I think it’s as simple as adding Base.MainInclude.ans = result to eval_tmpfile after line 261 (right before if isnothing(popup_params)). It seems to work for me, but I have not thoroughly tested it, nor am I certain that it doesn’t have bad side effects. Could you try making the change and drive it for a little while, and see if it seems safe to push to the main branch?

gcv commented 1 month ago

Feel free to open a PR if there’s a better way to implement this feature.

danielmatz commented 1 month ago

Wow, it really was that easy to do! I'll give it a try for a while and report back. Thanks!