Closed rdiaz02 closed 1 year ago
I've just added a possibility to display images in an Emacs buffer to EmacsVterm.jl. For this to work, you would need to apply the changes in PR #112. If you want to test it, I'd be happy for some feedback.
Thanks! I just tried it, but I must be doing something wrong. I installed EmacsVterm from Julia, modified my startup.jl that now is
using OhMyREPL
using Revise
atreplinit() do repl
@eval using EmacsVterm
EmacsVterm.options.image = true
# Optionally set EmacsVterm.options as you like (see below)
## EmacsVterm.options.markdown = false
end
and cloned your julia-repl
repo and checked-out branch emacsvterm.jl-integration.
[ Info: Emacs vterm detected
UndefVarError: options not defined
As expected, plots are not shown in an Emacs buffer, even if I have set EmacsVterm.options.image = true
.
EmacsVterm.display_on()
I getjulia> EmacsVterm.display_on()
ERROR: UndefVarError: display_on not defined
Stacktrace:
[1] getproperty(x::Module, f::Symbol)
@ Base ./Base.jl:31
[2] top-level scope
@ REPL[2]:1
But other features do work:
C-c C-d
I get the help to open in a *julia-doc*
buffer.I forgot to mention that you should use development version of EmacsVterm
. I've not yet made a new release with this functionality. Install it with:
]develop EmacsVterm
I just merged #112. This works fine for me, I plan to close when a release is tagged with EmacsVterm's current features.
Thanks! I checked the figure display in buffer and it works perfectly, except for Gadfly, where the plot is not shown (anywhere, as far as I can tell) but it is shown in a buffer by julia-snail. Example code:
## In buffer, by both julia-repl and julia-snail
using Plots
Plots.plot(rand(2, 3))
## Makie. In buffer by both julia-repl and snail
using CairoMakie
Makie.heatmap(rand(4, 4))
## Does not work with julia-repl: not shown.
## It is shown by snail
import Gadfly
Gadfly.plot(sin, 0, 2π)
P.S. In case someone stumbles upon this: figures were being shown as tiny squares. The culprit was this setting in my custom-set-variables
: '(current-language-environment "ASCII")
(I think that is a relic from the past). I don't know why that setting affects the display of figures in buffers, but it affected both julia-repl and julia-snail.
I just noticed that if display of images in Emacs buffers is used (EmacsVterm.options.markdown = false
in startup.jl or EmacsVterm.display_on()
in the REPL), then no output is shown in the REPL itself.
For example
EmacsVterm.display_on()
x = 5
x
## Nothing is shown
## Must do, for example
print(x)
I think I am missing something here. I would have expected, as per the README's "Images can be shown in an Emacs buffer. " that this setting would not have affected the display of results in the REPL. And I think these two are distinct ideas/desires:
Moreover, the behavior seems inconsistent (if I am understanding correctly the meaning of the options):
Setting EmacsVterm.options.image = false
or not setting it at all in startup.jl leads to values of variables not being printed in the REPL and figures not showing in Emacs buffers. If one then issues, EmacsVterm.display_on()
in the REPL figures still are not shown in Emacs buffers.
It seems that to be able to have EmacsVterm.display_on/off()
honored, one must have started with EmacsVterm.options.image = true
in startup.jl.
(I am leaving this here, as continuation of the former comments, but maybe I should move it to the EmacsVterm repo's issues?)
I just noticed that if display of images in Emacs buffers is used (EmacsVterm.options.markdown = false in startup.jl or EmacsVterm.display_on() in the REPL), then no output is shown in the REPL itself.
Yes. This was caused by EmacsVterm.display() not throwing exception for non-image data. Fixed with this commit.
I'll look at the other issues later or tomorrow. It's probably just a matter of supporting the right MIME types.
SVG support (needed for Gadfly) was added to EmacsVterm. @rdiaz02 does it work for you? Anyway, I'll make a release tomorrow.
Yes! Thanks, both things work: Gadfly and Emacs not eating anymore the non-display data.
Thanks to all for testing, new release is out.
I think this was fixed by #112.
Is it possible to have plots display in an Emacs buffer when using julia-repl?
Why? I've realized I really like this after displaying plots from R in Emacs buffers with the httpg package (https://github.com/nx10/httpgd) using with xwidgets.
With Julia, this is available with julia-snail (https://github.com/gcv/julia-snail#multimedia-and-plotting ; see discussion here: https://github.com/gcv/julia-snail/issues/15 and https://github.com/gcv/julia-snail/pull/21). This seems to have been available with julia-repl in the past with julia-img-view (https://github.com/dennisog/julia-img-view) but it hasn't been updated for more than three years, and no longer works (see also https://github.com/dennisog/julia-img-view/issues/2; I just tried it and, for example, the code tries to call no longer existing functions such as
julia-repl--live-buffer
).