From: Timothy <tecosaur@gmail.com>
To: org-mode-email <emacs-orgmode@gnu.org>
Subject: [PATCH] Refresh inline plotted images
Date: Sat, 24 Apr 2021 12:59:49 +0800 [thread overview]
Message-ID: <87r1j0mg56.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
Hi All,
This patch improves the result of running org-plot in the following
situation
#+plot: ... file:"somefile.png"
[[file:somefile.png]]
Previously, when somefile.png is re-plotted the [[file:]] inline image
did not refresh. With this patch, after plotting, overlays of the
replotted image are refreshed.
--
Timothy
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-plot-Refresh-inline-images-after-plotting.patch --]
[-- Type: text/x-patch, Size: 1786 bytes --]
From 5c848c186f2dd4d77b0dcc1035b3c889a4b023a2 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Sat, 24 Apr 2021 12:49:26 +0800
Subject: [PATCH] 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 28cff94f2..65bc71074 100644
--- a/lisp/org-plot.el
+++ b/lisp/org-plot.el
@@ -610,6 +610,13 @@ (defun org-plot/gnuplot-script (table data-file num-cols params &optional prefac
",\\\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
@@ -697,7 +704,10 @@ (defun org-plot/gnuplot (&optional params)
(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)
--
2.31.1
next reply other threads:[~2021-04-24 5:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-24 4:59 Timothy [this message]
2021-04-26 6:54 ` [PATCH] Refresh inline plotted images Bastien
2021-04-26 14:54 ` Timothy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1j0mg56.fsf@gmail.com \
--to=tecosaur@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.