0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 22:07:49 +00:00

org-plot: Refresh inline images after plotting

* lisp/org-plot.el (org-plot/redisplay-img-in-buffer): New function
which searches the current Org buffer for overlays of a certain image,
and refreshes those overlays.
(org-plot/gnuplot): Use `org-plot/redisplay-img-in-buffer' after
plotting to redisplay any associated inline images.
This commit is contained in:
TEC 2021-04-26 22:48:28 +08:00
parent 0f7d2823fd
commit dadbd025fa
Signed by: tec
GPG key ID: 779591AFDB81F06C

View file

@ -616,6 +616,13 @@ manner suitable for prepending to a user-specified script."
",\\\n "))))
script)))
(defun org-plot/redisplay-img-in-buffer (img-file)
"Find any overlays for IMG-FILE in the current Org buffer, and refresh them."
(dolist (img-overlay org-inline-image-overlays)
(when (string= img-file (plist-get (cdr (overlay-get img-overlay 'display)) :file))
(when (file-exists-p img-file)
(image-refresh (overlay-get img-overlay 'display))))))
;;-----------------------------------------------------------------------------
;; facade functions
;;;###autoload
@ -703,7 +710,10 @@ line directly before or after the table."
(gnuplot-mode)
(gnuplot-send-buffer-to-gnuplot))
;; Cleanup.
(bury-buffer (get-buffer "*gnuplot*")))))
(bury-buffer (get-buffer "*gnuplot*"))
;; Refresh any displayed images
(when (plist-get params :file)
(org-plot/redisplay-img-in-buffer (expand-file-name (plist-get params :file)))))))
(provide 'org-plot)