>> 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.
>
> There is a number of solutions spread across user configs.
> Mine has
> (add-hook
> 'org-babel-after-execute-hook
> (lambda ()
> (unless (eq this-command 'org-babel-tangle)
> (org-display-inline-images
> nil nil
> (save-excursion (org-back-to-heading-or-point-min t) (point))
> (save-excursion (or (outline-next-heading) (point-max)))))))
I use this:
(defun my/org-redisplay-babel-result ()
(save-excursion
(condition-case err
(when-let* ((beg (org-babel-where-is-src-block-result))
(elem (and (goto-char beg) (org-element-context)))
(end (- (org-element-property :end elem)
(org-element-property :post-blank elem))))
(org-link-preview-region nil 'refresh beg end))
(error (message "Could not display images: %S" err)))))
(add-hook 'org-babel-after-execute-hook #'my/org-redisplay-babel-result)
This presumes that the output of the babel block is a path to an image.
Karthik