R&Emacs中的弹出窗口

时间:2021-02-14 22:57:43

I am using ESS in order to stay in Emacs when working with R. Whenever I create a plot a new pop-up appears with the graph. This new window seems to be a part of the R process called inside Emacs. As such the new window is not part of the buffer-list and seems to lie outside the Emacs environment.

我在使用ES时使用ESS以便留在Emacs中。每当我创建一个绘图时,图形中都会出现一个新的弹出窗口。这个新窗口似乎是Emacs内部调用的R进程的一部分。因此,新窗口不是缓冲区列表的一部分,并且似乎位于Emacs环境之外。

Can a new window created by R, containing e.g. graphs called by plot() or respective functions in ggplot2/lattice, be forced to stay inside the Emacs environment? So that the plot is available as a new buffer.

可以由R创建的新窗口包含例如plot()或ggplot2 / lattice中各个函数调用的图形被强制保留在Emacs环境中?因此该图可用作新缓冲区。

Thanks!

5 个解决方案

#1


4  

No, sorry, it cannot. Emacs buffers are text. Graphics windows are graphics devices.

不,对不起,它不能。 Emacs缓冲区是文本。图形窗口是图形设备。

But you can do this yourself. Before plotting, or even at the begin of a session, say

但你可以自己做。在绘图之前,甚至在会话开始之前,比如说

pdf(file="/tmp/myplotfile.pdf")

and now plots will go there. You can then open the pdf file in Emacs, and recent versions include a pdf preview inside Emacs (at least on my Linux boxen, not sure if I needed extra modes for that). That would come close to your requirements.

现在情节会去那里。然后,您可以在Emacs中打开pdf文件,最近的版本包括Emacs中的pdf预览(至少在我的Linux boxen上,不确定我是否需要额外的模式)。那将接近你的要求。

#2


8  

Oh yes it can...

哦,是的,它可以......

In ESS, do this:

在ESS中,执行以下操作:

png(file="tmp.png")
plot(1:10)
dev.off()
# [[tmp.png]]

Nothing. Now do ESC X iimage-mode (yes, two i's there).

没有。现在做ESC X iimage-mode(是的,两个我在那里)。

This puts your buffer into iimage minor mode, it should spot the [[tmp.png]] and load your image in there. This should be easily automatable. This is the first time I've discovered this for myself so there's probably better ways to do it.

这会将您的缓冲区置于iimage较小模式,它应该发现[[tmp.png]]并将图像加载到那里。这应该很容易自动化。这是我第一次为自己发现这个,所以可能有更好的方法。

There's clearly been some chatter on the ESS list about this:

在ESS列表中显然有一些关于此的喋喋不休:

https://stat.ethz.ch/pipermail/ess-help/2009-August/005474.html

but I am surprised its not in the ESS core yet...

但我很惊讶它还没有在ESS核心......

#3


0  

try this:

X11()   #  starts a X11 graphics device
plot(c(1:10),c(1:10))
savePlot(filename = "try_save_X11.png",type = c("png"))

#4


0  

This solution is quite dramatic and may not work for you since it will affect your workflow outside ESS. But exwm is an X window manager in emacs that allows you to have your non-emacs windows as emacs buffers. It would allow you to have your R plots as emacs buffers, fully mangeable with the usual emacs window and buffer keybindings.

此解决方案非常引人注目,可能对您无效,因为它会影响您在ESS之外的工作流程。但exwm是emacs中的X窗口管理器,允许您将非emacs窗口作为emacs缓冲区。它允许你将你的R图作为emacs缓冲区,完全可以使用通常的emacs窗口和缓冲区键绑定。

Here is a very simple example to show what that would look like:

这是一个非常简单的示例,用于显示其外观:

R&Emacs中的弹出窗口

#5


0  

This does not exactly answer the OP's question because this goes outside of ESS but it still may be relevant to some because it still relates to using R to generate graphics that can be viewed inside of Emacs.

这并没有完全回答OP的问题,因为它超出了ESS,但它仍然可能与某些相关,因为它仍然与使用R生成可在Emacs内部查看的图形有关。

You can do this using Emacs iPython Notebook (ein). You have to set up Jupyter first but after that it's pretty straightforward and can work with different kernels (R, Python, Julia, etc.). Below is a screenshot

您可以使用Emacs iPython Notebook(ein)执行此操作。你必须首先设置Jupyter,但之后它非常简单,可以使用不同的内核(R,Python,Julia等)。下面是截图

R&Emacs中的弹出窗口

#1


4  

No, sorry, it cannot. Emacs buffers are text. Graphics windows are graphics devices.

不,对不起,它不能。 Emacs缓冲区是文本。图形窗口是图形设备。

But you can do this yourself. Before plotting, or even at the begin of a session, say

但你可以自己做。在绘图之前,甚至在会话开始之前,比如说

pdf(file="/tmp/myplotfile.pdf")

and now plots will go there. You can then open the pdf file in Emacs, and recent versions include a pdf preview inside Emacs (at least on my Linux boxen, not sure if I needed extra modes for that). That would come close to your requirements.

现在情节会去那里。然后,您可以在Emacs中打开pdf文件,最近的版本包括Emacs中的pdf预览(至少在我的Linux boxen上,不确定我是否需要额外的模式)。那将接近你的要求。

#2


8  

Oh yes it can...

哦,是的,它可以......

In ESS, do this:

在ESS中,执行以下操作:

png(file="tmp.png")
plot(1:10)
dev.off()
# [[tmp.png]]

Nothing. Now do ESC X iimage-mode (yes, two i's there).

没有。现在做ESC X iimage-mode(是的,两个我在那里)。

This puts your buffer into iimage minor mode, it should spot the [[tmp.png]] and load your image in there. This should be easily automatable. This is the first time I've discovered this for myself so there's probably better ways to do it.

这会将您的缓冲区置于iimage较小模式,它应该发现[[tmp.png]]并将图像加载到那里。这应该很容易自动化。这是我第一次为自己发现这个,所以可能有更好的方法。

There's clearly been some chatter on the ESS list about this:

在ESS列表中显然有一些关于此的喋喋不休:

https://stat.ethz.ch/pipermail/ess-help/2009-August/005474.html

but I am surprised its not in the ESS core yet...

但我很惊讶它还没有在ESS核心......

#3


0  

try this:

X11()   #  starts a X11 graphics device
plot(c(1:10),c(1:10))
savePlot(filename = "try_save_X11.png",type = c("png"))

#4


0  

This solution is quite dramatic and may not work for you since it will affect your workflow outside ESS. But exwm is an X window manager in emacs that allows you to have your non-emacs windows as emacs buffers. It would allow you to have your R plots as emacs buffers, fully mangeable with the usual emacs window and buffer keybindings.

此解决方案非常引人注目,可能对您无效,因为它会影响您在ESS之外的工作流程。但exwm是emacs中的X窗口管理器,允许您将非emacs窗口作为emacs缓冲区。它允许你将你的R图作为emacs缓冲区,完全可以使用通常的emacs窗口和缓冲区键绑定。

Here is a very simple example to show what that would look like:

这是一个非常简单的示例,用于显示其外观:

R&Emacs中的弹出窗口

#5


0  

This does not exactly answer the OP's question because this goes outside of ESS but it still may be relevant to some because it still relates to using R to generate graphics that can be viewed inside of Emacs.

这并没有完全回答OP的问题,因为它超出了ESS,但它仍然可能与某些相关,因为它仍然与使用R生成可在Emacs内部查看的图形有关。

You can do this using Emacs iPython Notebook (ein). You have to set up Jupyter first but after that it's pretty straightforward and can work with different kernels (R, Python, Julia, etc.). Below is a screenshot

您可以使用Emacs iPython Notebook(ein)执行此操作。你必须首先设置Jupyter,但之后它非常简单,可以使用不同的内核(R,Python,Julia等)。下面是截图

R&Emacs中的弹出窗口