From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mP6oJOlrc19fZAAA0tVLHw (envelope-from ) for ; Tue, 29 Sep 2020 17:16:25 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id YMppIOlrc19uWgAAbx9fmQ (envelope-from ) for ; Tue, 29 Sep 2020 17:16:25 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0A08D9402AC for ; Tue, 29 Sep 2020 17:16:24 +0000 (UTC) Received: from localhost ([::1]:34266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNJEl-0007ns-Bv for larch@yhetil.org; Tue, 29 Sep 2020 13:16:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNJDv-0007bA-JR for emacs-orgmode@gnu.org; Tue, 29 Sep 2020 13:15:31 -0400 Received: from pie.tf ([62.75.142.128]:36350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNJDt-0002kC-RS for emacs-orgmode@gnu.org; Tue, 29 Sep 2020 13:15:31 -0400 Received: from leintor.e.ffh.zone ([81.3.6.94] helo=localhost) by pie.tf with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1kNJDp-0007cC-BA; Tue, 29 Sep 2020 17:15:26 +0000 From: Ferdinand Pieper To: emacs-orgmode@gnu.org Subject: [PATCH] Persistently save downloaded inline remote images Date: Tue, 29 Sep 2020 19:15:24 +0200 Message-ID: <87blhosdw3.fsf@ims.uni-hannover.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=62.75.142.128; envelope-from=fer@pie.tf; helo=pie.tf X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/29 13:01:00 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 3.29 X-TUID: w63cL4dllpXP --=-=-= Content-Type: text/plain 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, --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org.el-Persistently-save-downloaded-inline-remote-im.patch >From aa34ad1176f4599c5a3c2678806644f16a3d22a2 Mon Sep 17 00:00:00 2001 From: fpi 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 --=-=-=--