组织模式内联图像不工作(远程使用TRAMP)



我在使用TRAMP的远程机器上使用emacs org-mode。我将代码单元连接到jupyter服务器(在该远程机器上),在那里启动python 3内核。代码执行工作完美,我也可以用matplotlib创建情节。当.png在正确的临时文件位置生成时,代码单元格的输出是指向该文件的(相对)链接,而不是像预期的那样内联显示。

代码块示例如下:

#+BEGIN_SRC jupyter-python :session /jpy:localhost#9090:TEST
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(range(10), range(10))
#+END_SRC
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f1c43a289a0> |
[[file:./.ob-jupyter/e1eecf5d59de9bfa1d3468867a64aadf4b1a6261.png]]
:END:

C-c C-x C-v给出消息:'No images to display inline'

C-c o在不同的缓冲区中正确打开并显示文件。

我希望文件能在org模式缓冲区中正确内联显示。

我尝试手动更改链接到一个TRAMP路径,看起来像这样:

[[file:/ssh:MYSERVER:/PATH_TO_TEMP_FOLDER/.ob-jupyter/e1eecf5d59de9bfa1d3468867a64aadf4b1a6261.png]]

也允许我用C-c o打开文件,但不会内联显示文件(与上面描述的行为相同)

如果我直接打开jupyter-repl会话并键入fig(在执行上述代码块之后),则在jupyter-repl缓冲区

中显示如图所示的图。如果我在本地运行jupyter会话,内联绘图工作如预期的


更新:

我意识到如果在链接上执行C-f打开文件,链接将扩展为无效的临时链接,这会抛出以下错误消息:

File is missing: /ssh:bih:/PATH_TO_CORRECT_FOLDER/00_test/file:./.ob-jupyter/

注意链接末尾的file:./不属于那里。所以我认为在TRAMP和org模式(或emacs-jupyter)之间的某个地方出了问题。有什么办法解决这个问题吗?

C-h v org-display-remote-inline-images说:

org-display-remote-inline-images is a variable defined in ‘org.el’.
Its value is ‘skip’
How to display remote inline images.
Possible values of this option are:
skip        Don’t display remote images.
download    Always download and display remote images.
cache       Display remote images, and open them in separate buffers
for caching.  Silently update the image buffer when a file
change is detected.

检查值,也许可以自定义变量来做skip以外的事情。

最新更新