emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FR] Automatically display images in resutls of evaluation (was: [PATCH


From: Ihor Radchenko
Subject: [FR] Automatically display images in resutls of evaluation (was: [PATCH v4.0] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer)
Date: Sun, 18 Aug 2024 10:34:49 +0000

stardiviner <numbchild@gmail.com> writes:

> I have an idea, would you like to add an function in bellowing:
>
> #+begin_src emacs-lisp
> (defun org-toggle-inline-images-in-results ()
>   "Toggle inline images in babel source block results."
>   (save-excursion
>     ;; [C-c C-v C-o] `org-babel-open-src-block-result'
>     (let ((begin (org-babel-where-is-src-block-result))
>           (end (progn
>                  (end-of-line)
>                  (skip-chars-forward " \r\t\n")
>                  (looking-at org-link-bracket-re)
>                  ;; (org-babel-read-result)
>                  (point))))
>       (org-toggle-inline-images-command nil begin end))))
>
> (add-hook 'org-babel-after-execute-hook
> 'org-toggle-inline-images-in-results)
> #+end_src
>
> WDYT? after all I originally propose this patch for this purpose to
> improve the babel result inline image toggle displaying performance.

I do not mind this kind of feature, but `org-babel-after-execute-hook'
is probably not the best place - it may be triggered noninteractively,
including in Emacs running in batch mode, where displaying images is
impossible. In particular, `org-babel-tangle' does it.

Also, you do not need `org-toggle-inline-images-command' for this. You
do not need "toggle" in general - what if an image was previously
displayed and you evaluate an src block?

A simple `org-display-inline-images' would do (with REFRESH argument).

I suggest to put this (1) under a new custom option; (2) only when
Emacs can actually display images.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]