[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org dadbd02 2/2: org-plot: Refresh inline images after
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org dadbd02 2/2: org-plot: Refresh inline images after plotting |
Date: |
Mon, 26 Apr 2021 10:57:10 -0400 (EDT) |
branch: externals/org
commit dadbd025fa5d4b7a35a58004eff51af67da6f744
Author: TEC <tec@tecosaur.com>
Commit: TEC <tec@tecosaur.com>
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.
---
lisp/org-plot.el | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lisp/org-plot.el b/lisp/org-plot.el
index 7d6c532..ee54d61 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -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)