emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Patch] org-display-inline-images: Add support for remote images
@ 2014-11-22  4:43 Kit-Yan Choi
  2014-11-25  8:32 ` Nicolas Goaziou
  0 siblings, 1 reply; 10+ messages in thread
From: Kit-Yan Choi @ 2014-11-22  4:43 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 381 bytes --]

Hi,

I would like to submit a patch to support displaying remote images inline
in Org-mode.  Attached is the formatted patch (or github branch here
<https://github.com/kitchoi/org-mode/commit/2e600da455c371754f028ddaaed1ae1724cbe6b6>
.)

I have tested the code with "make test".  FSF document is signed (waiting
for gnu to send it back).

Feedbacks are most welcome.  Thanks.

Kit

[-- Attachment #1.2: Type: text/html, Size: 542 bytes --]

[-- Attachment #2: 0001-org.el.diff --]
[-- Type: text/plain, Size: 1694 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 1f33d2a..aaa5c9b 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19338,7 +19338,7 @@ boundaries."
 			    (not (cdr (org-element-contents parent)))))
 		      (org-string-match-p file-extension-re
 					  (org-element-property :path link)))
-	     (let ((file (expand-file-name (org-element-property :path link))))
+	     (let ((file (substitute-in-file-name (expand-file-name (org-element-property :path link)))))
 	       (when (file-exists-p file)
 		 (let ((width
 			;; Apply `org-image-actual-width' specifications.
@@ -19376,10 +19376,29 @@ boundaries."
 			     'org-image-overlay)))
 		   (if (and (car-safe old) refresh)
 		       (image-refresh (overlay-get (cdr old) 'display))
-		     (let ((image (create-image file
-						  (and width 'imagemagick)
-						  nil
-						  :width width)))
+		     (let* ((image 
+			     (let ((newname
+				    (if (org-file-remote-p file)
+					(let* ((tramp-tmpdir (concat
+							      (if (featurep 'xemacs)
+								  (temp-directory)
+								temporary-file-directory)
+							      "/tramp"
+							      (org-file-remote-p file)
+							      (file-name-directory
+							       (org-babel-local-file-name file))))
+					       (newname (concat
+							 tramp-tmpdir 
+							 (file-name-nondirectory file))))
+					  (make-directory tramp-tmpdir t)
+					  (if (tramp-handle-file-newer-than-file-p file newname)
+						(tramp-compat-copy-file file newname t t))
+					  newname)
+				      file)))
+			       (create-image newname
+					     (and width 'imagemagick)
+					     nil
+					     :width width))))
 		       (when image
 			 (let* ((link
 				 ;; If inline image is the description

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-11-29 10:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-22  4:43 [Patch] org-display-inline-images: Add support for remote images Kit-Yan Choi
2014-11-25  8:32 ` Nicolas Goaziou
2014-11-25 15:15   ` Kit-Yan Choi
2014-11-25 15:23     ` Rasmus
2014-11-25 15:29     ` Kit-Yan Choi
2014-11-25 15:39       ` Michael Albinus
2014-11-25 15:45         ` Kit-Yan Choi
2014-11-25 17:04           ` Michael Albinus
2014-11-26 17:13             ` Kit-Yan Choi
2014-11-29 10:50               ` Michael Albinus

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).