1

I am having a strange problem with org-mode. When I update/change a linked image it does not update in the buffer.

My test uses babel for convenience, but this is true for all images. I already have the following set: (add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)

When I run the following, I see a plot image as expected.

#+BEGIN_SRC R :results output graphics file :file test.png 
    plot(1:2, 1:2, type='p')
    abline(h=1,lty=2)
    abline(v=1.5)
#+END_SRC

But when I change the plotting code (by commenting out one of the abline commands), the displayed result image doesn't update.

It's as if emacs has cached the image, but I cannot find any way to clear that cache.

  • Did you re-evaluate the src block? The "cache" is the file `test.png` in the current directory, so you can check whether that gets updated when you re-evaluate the block. If that happens, then the hook should redisplay the updated image. – NickD May 17 '23 at 11:59
  • Yes I re-evaluated the src block and the test.png file is, indeed, updated. But the image in the org buffer is not updated even after running org-redisplay-inline-images manually – Richard Longland May 18 '23 at 15:06
  • Does it work if you `M-x org-toggle-inline-images` twice? – NickD May 18 '23 at 15:16
  • Sorry for the delay. I was on vacation without the laptop. @NickD: No, toggling inline images twice does not work – Richard Longland May 30 '23 at 08:54
  • I am not great with lisp, so I don't understand why, but the following solution (to a different problem) fixed this issue: https://stackoverflow.com/questions/15407485/inline-pdf-images-in-org-mode?rq=2 – Richard Longland May 30 '23 at 09:03

1 Answers1

0

It may caused by emacs image cache. Add (add-hook 'org-babel-after-execute-hook 'clear-image-cache) works for me.

galaxy
  • 26
  • 1