1

Normally I do all work locally (data analysis, image generation, etc.). However, recently I've started using the server more. When working locally I'll write the analysis code (in Python), generate the image, open the image to see what needs updated, rerun the code and see how the image changes. When working on the server this is not possible (I have to scp or rsync the new image to my computer and then open): I would like to see these images updated without these additional steps.

I tried using tramp to ssh into the server. This allows me to open the image in an emacs buffer, but does not allow me to scroll through multiple images (apparently image-dired does not work on remote files). Another issue is that the image, when opened, is bigger than the buffer, making visualization difficult.

I also tried creating an org file on the server and linking the image(s), but this results in an emacs error "No images to display inline". I tried this with and without captions, to no avail.

Is there a way to view these images in closer to real time like I do locally, or to at least view them in an emacs buffer so they fit nicely and allow me to scroll between images?

Here is the example remote org-mode file I used for testing. This same file worked when I used it locally.

#+STARTUP: inlineimages

[[file:test0.png]]
tnknepp
  • 250
  • 2
  • 11
  • I can open a directory on the server in my local emacs, using Tramp. I can open files in the directory using `f`, although there's a delay while the image is downloaded. Is that enough? If you need something more, please describe in detail. – NickD Apr 04 '22 at 19:03
  • I do something like this with orgmode. If you provide the details of your org file, we may be able to help you get that working – Tyler Apr 04 '22 at 21:55
  • @Tyler: I'm not sure there *is* an Org mode file here. – NickD Apr 04 '22 at 23:44
  • @NickD OP said he tried to accomplish his objective with org mode (among other things), and I think it is possible to do. I have done something which I think is very similar. – Tyler Apr 05 '22 at 00:37
  • Ah, missed that - thanks! – NickD Apr 05 '22 at 01:28
  • I have no knowledge of any current version of org-mode, but am somewhat familiar with earlier versions and also some Tramp stuff. Can you use links that use the Tramp file path protocal for stuff in cyberspace and `revert-buffer` to force the buffer to update everything (pulling the updated image from cyberspace)? There is also an Emacs mode that automates reverting the buffer when changes occur, but I'd need to Google to refresh my recollection. – lawlist Apr 05 '22 at 06:02
  • @Tyler I updated the post to contain an example (bare bones) org-mode file. – tnknepp Apr 05 '22 at 10:22
  • If you open the org file locally, then it has to include remote links. Otherwise, you can only get to the links if you open it locally *on the server*. Try `[[file:/scp:user@server:/path/to/test0.png]]`. – NickD Apr 05 '22 at 17:00
  • @NickD Thanks. What I meant was I see the images when everything is local (org file, png files). However, when I use tramp to load an org file on the server (org file and image files are all on the server) I do not see the images. I get the "No images to display inline" error. – tnknepp Apr 05 '22 at 17:07
  • Exactly: you need to use remote links in your org file. When you open the org file remotely, the remote links will work. When you open the org file locally on the server, they will *still* work, but somewhat inefficiently since you are doing an ssh from the server to *itself* to get the files. With the links as you have them, it will *only* work when you open the org file locally on the server. – NickD Apr 05 '22 at 17:20
  • But as @Tyler points out in his answer, relative links in the remore Org file, will turn into remote links through the magic of Tramp. So if you open the remote Org file with Tramp, your current directory should be the remote directory and relative links in the file *should* open properly. And If you customize `org-display-remote-inline-images` as mentioned in my comment (watch out for the typo!), then you should be able to get inline images as well. – NickD Apr 07 '22 at 20:10

1 Answers1

1

Not quite a complete answer, but if you open an org file on a remote server:

C-x C-f /ssh:server:file

And put a link in that file:

Here is my image:

[[./iris.png]]

You will get an active link. Note that the link path is relative to the remote file. If you're editing a remote file, orgmode looks for links in that file on the remote machine.

This doesn't work as an inline-image, C-c C-x C-v won't do anything. But if you press enter on the link, it will open in an Emacs window for you. You can 'refresh' the file by pressing g while in that window. If you know when the file has changed, you can get 'near-realtime' updates this way. It won't update automatically on change though. I tried auto-revert-mode, which doesn't seem to work remotely (I only did a quick test).

You can use this approach to generate image files on the remote machine with orgmode code blocks, and view the resulting graphics from your local emacs.

Tyler
  • 21,719
  • 1
  • 52
  • 92
  • That's a neat trick! – NickD Apr 05 '22 at 22:10
  • Have you tried setting `org-display-remote-online-images` to `download`? Or perhaps `cache`? It's set to `skip` by default, presumably to avoid long delays, but it's worth trying in this case. I'm not sure how strong the cache consistency is though: it may need manual intervention. – NickD Apr 06 '22 at 00:39
  • BTW, `C-x C-v C-i` does not seem right: `org-toggle-inline-images` is bound to `C-c C-x C-v` in my case. – NickD Apr 06 '22 at 00:50
  • @NickD thanks. org keybindings are pretty ugly, I don't remember many that go more than 2 keys deep. – Tyler Apr 06 '22 at 01:05
  • Gaah - that should be `org-display-remote-inline-images`. – NickD Apr 07 '22 at 20:11