From 69340149f97445b3c6e728c692a96c18937feeb9 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 27 Jan 2022 01:18:02 +0100 Subject: [PATCH] fix(org): don't refresh images while exporting/tangling Also limits the scope of org-display-inline-images to the current src block. org-display-inline-images was previously used on the entire subtree, which was slower than it needed to be (especially while exporting/tangling org). --- modules/lang/org/config.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index e1118a9bc..674c7928a 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -305,7 +305,19 @@ Also adds support for a `:sync' parameter to override `:async'." ;; Refresh inline images after executing src blocks (useful for plantuml or ;; ipython, where the result could be an image) - (add-hook 'org-babel-after-execute-hook #'org-redisplay-inline-images) + (add-hook! 'org-babel-after-execute-hook + (defun +org-redisplay-inline-images-in-babel-result-h () + (unless (or + ;; ...but not while Emacs is exporting an org buffer (where + ;; `org-display-inline-images' can be awfully slow). + (bound-and-true-p org-export-current-backend) + ;; ...and not while tangling org buffers (which happens in a temp + ;; buffer where `buffer-file-name' is nil). + (string-match-p "^ \\*temp" (buffer-name))) + (org-display-inline-images + nil nil + (org-babel-where-is-src-block-result) + (org-babel-result-end))))) (after! python (unless org-babel-python-command