Probably everyone on this list who uses Org code blocks to generate graphics 
has something in their configuration file that refreshes the image in the 
buffer when its code block is run and the image is regenerated.  What is the 
(most) correct way to do that? 

I used to have these in my init, copied in years ago when I first started using 
Org:

# ----- no longer used 
(add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
(add-hook 'org-mode-hook (lambda () (org-toggle-inline-images)))
# -----

Both of these are obsolete in Org 9.8.  I think they were conflicting and 
causing me trouble with a big Org file that has a lot of tables and R in it.  
Now I have:

# -----
(setq org-display-inline-images t) ;; Enable images in buffers
(setq org-startup-with-inline-images nil) ;; Don't show them automatically, can 
use #+startup: inlineimages
# -----

And I use this hook.  Is this the right way to do it?

# -----
(add-hook 'org-babel-after-execute-hook 'org-link-preview-refresh)
# -----

I think that refreshes all the images in the buffer, but what if I just want it 
to refresh the one that was just changed, the one made by the code block where 
I just hit C-c C-c?  

This isn't documented in the manual, and looking around on the web I see a lot 
of old copied-and-pasted code.  I'm happy to try to update the manual with how 
to do this.

Thanks,

Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada

Reply via email to