9

Recently I've noticed the function I had been using to do refresh had stopped working and I had to change to a simpler call.

I used to have:

(defun k/org-babel-refresh-inline-images ()
  (org-display-inline-images nil t))

(add-hook 'org-babel-after-execute-hook 'k/org-babel-refresh-inline-images)

which had been recommended on the mailing list.

However, that stopped working and I've found:

 (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)

to work, but I'm not sure why the original stopped working. Presumably, the original version might be more efficient if it worked. Why doesn't it, and why was the original preferred?

2 Answers 2

9

This works for me on Emacs 24.4.1 with OS X using the included org-mode (note the use of redisplay vs. display).

(defun shk-fix-inline-images ()
  (when org-inline-image-overlays
    (org-redisplay-inline-images)))

(after-loading 'org
  (add-hook 'org-babel-after-execute-hook 'shk-fix-inline-images))
1
  • 3
    With Emacs 26.1, after-loading is not defined and according to the Emacs Manual I had to use with-eval-after-load instead.
    – applesoup
    Aug 23, 2019 at 9:50
2

For me, only the snippet below worked:

;; Always redisplay inline images after executing SRC block
(eval-after-load 'org
  (add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images))

For details, in my case, org-inline-image-overlays was behaving in the opposite manner as it should in the "when" statement: it was being set to a value only when an overlay was being shown. Maybe due to changes in later versions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.