From: Kit-Yan Choi <kit@kychoi.org>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: [Patch] org-display-inline-images: Add support for remote images
Date: Tue, 25 Nov 2014 10:45:50 -0500 [thread overview]
Message-ID: <CAKHbGXUefCDumkwOEKsSZ3qcRq=-dWZTaanhokU7M1AVehmZ-Q@mail.gmail.com> (raw)
In-Reply-To: <87bnnv1e95.fsf@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 2380 bytes --]
Michael,
Thanks for the suggestion. Indeed `file-local-copy' would have made the
code cleaner. Yet `file-local-copy' generates a new filename each time
it's run. But I wanted to allow the code to check whether the remote image
has already been fetched before and so skip unnecessary file transfer,
which takes time (think of it like "rsync -a"). Therefore I wanted to
preserve the remote path under a temporary directory.
Best,
Kit
On Tue, Nov 25, 2014 at 10:39 AM, Michael Albinus <michael.albinus@gmx.de>
wrote:
> Kit-Yan Choi <kit@kychoi.org> writes:
>
> > Ah my apologies. I forgot I had to use `file-name-directory' for
> > creating the path to the temporary directory (too long ago since I did
> > this). Here is the corrected version.
> >
> > --- a/lisp/org.el
> > +++ b/lisp/org.el
> > @@ -19340,7 +19340,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.
> > @@ -19378,10 +19378,25 @@ 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
> > + (create-image (if (org-file-remote-p file)
> > + (let* ((tramp-tmpdir (concat
> > + (if (featurep 'xemacs)
> > + (temp-directory)
> > + temporary-file-directory)
> > + "/tramp"
> > + (file-name-directory (expand-file-name file))))
> > + (newname (concat
> > + tramp-tmpdir
> > + (file-name-nondirectory (expand-file-name file)))))
> > + (make-directory tramp-tmpdir t)
> > + (if (file-newer-than-file-p file newname)
> > + (copy-file file newname t t))
> > + newname)
> > + file)
> > + (and width 'imagemagick)
> > + nil
> > + :width width)))
> > (when image
> > (let* ((link
> > ;; If inline image is the description
>
> This code looks much to complicate to me. Wouldn't a simple
> file-local-copy suffice? You don't need to care whether the file is
> remote (let Tramp do the job) or local (there won't be a copy).
>
> Best regards, Michael.
>
[-- Attachment #2: Type: text/html, Size: 3226 bytes --]
next prev parent reply other threads:[~2014-11-25 15:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2014-11-25 17:04 ` Michael Albinus
2014-11-26 17:13 ` Kit-Yan Choi
2014-11-29 10:50 ` Michael Albinus
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='CAKHbGXUefCDumkwOEKsSZ3qcRq=-dWZTaanhokU7M1AVehmZ-Q@mail.gmail.com' \
--to=kit@kychoi.org \
--cc=emacs-orgmode@gnu.org \
--cc=michael.albinus@gmx.de \
/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.