From: Ferdinand Pieper <fer@pie.tf>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Persistently save downloaded inline remote images
Date: Tue, 29 Sep 2020 19:15:24 +0200 [thread overview]
Message-ID: <87blhosdw3.fsf@ims.uni-hannover.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 272 bytes --]
Currently remote images are downloaded upon each display.
As most of the time the images do not change in between redisplays, we can instead buffer the images locally and only update the local copy when the remote image is updated.
Attached is a proposed patch.
Best,
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-Persistently-save-downloaded-inline-remote-im.patch --]
[-- Type: text/x-diff, Size: 1663 bytes --]
From aa34ad1176f4599c5a3c2678806644f16a3d22a2 Mon Sep 17 00:00:00 2001
From: fpi <git@pie.tf>
Date: Tue, 23 Jun 2020 15:59:28 +0200
Subject: [PATCH] org.el: Persistently save downloaded inline remote images
* lisp/org.el (org--create-inline-image): Save downloaded inline
remote images to temporary directory to persist them for future
`org-display-inline-images' calls.
---
lisp/org.el | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 4d46b4173..7b649d6d0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16277,10 +16277,22 @@ according to the value of `org-display-remote-inline-images'."
(file-or-data
(pcase org-display-remote-inline-images
((guard (not remote?)) file)
- (`download (with-temp-buffer
- (set-buffer-multibyte nil)
- (insert-file-contents-literally file)
- (buffer-string)))
+ (`download (let ((new (concat temporary-file-directory
+ "tramp/"
+ (file-remote-p file 'host)
+ (file-local-name file))))
+ ;; dont download file if local copy exists & is newer than remote
+ (if (and (file-exists-p new)
+ (file-newer-than-file-p new file))
+ (with-temp-buffer
+ (set-buffer-multibyte nil)
+ (insert-file-contents-literally new)
+ (buffer-string))
+ (with-temp-file new
+ (make-directory (file-name-directory new) t)
+ (set-buffer-multibyte nil)
+ (insert-file-contents-literally file)
+ (buffer-string)))))
(`cache (let ((revert-without-query '(".")))
(with-current-buffer (find-file-noselect file)
(buffer-string))))
--
2.20.1
next reply other threads:[~2020-09-29 17:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 17:15 Ferdinand Pieper [this message]
2020-12-07 5:54 ` [PATCH] Persistently save downloaded inline remote images Kyle Meyer
2020-12-07 15:17 ` Jack Kamm
2021-04-27 20:39 ` Bastien
2021-04-27 20:40 ` Bastien
2022-06-20 21:39 ` Jack Kamm
2022-06-21 3:39 ` Ihor Radchenko
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87blhosdw3.fsf@ims.uni-hannover.de \
--to=fer@pie.tf \
--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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).