From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kit-Yan Choi Subject: Re: [Patch] org-display-inline-images: Add support for remote images Date: Tue, 25 Nov 2014 10:29:35 -0500 Message-ID: References: <87vbm3of2o.fsf@selenimh.mobile.lan> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a11349f2e147d160508b094f3 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtI3j-0000d0-4f for emacs-orgmode@gnu.org; Tue, 25 Nov 2014 10:29:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtI3b-0007Wn-Rg for emacs-orgmode@gnu.org; Tue, 25 Nov 2014 10:29:43 -0500 Received: from mail-qa0-x22b.google.com ([2607:f8b0:400d:c00::22b]:56618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtI3b-0007Wb-JP for emacs-orgmode@gnu.org; Tue, 25 Nov 2014 10:29:35 -0500 Received: by mail-qa0-f43.google.com with SMTP id bm13so532932qab.16 for ; Tue, 25 Nov 2014 07:29:35 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Kit-Yan Choi , emacs-orgmode@gnu.org --001a11349f2e147d160508b094f3 Content-Type: multipart/alternative; boundary=001a11349f2e147d100508b094f1 --001a11349f2e147d100508b094f1 Content-Type: text/plain; charset=UTF-8 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 On Tue, Nov 25, 2014 at 10:15 AM, Kit-Yan Choi wrote: > Thank you for your comments! They are very helpful. > > > Thanks for your patch. However, I wonder if we really want this. Remote > > images could be slow to fetch, and it would make buffer unusable. > > I personally needed this functionality. I have tried to reduce the amount > of time spent on fetching the images by checking whether the images have > been fetched before and whether the remote files are newer. Yes these > communications take time as it should be expected if one opens an org file > remotely (therefore connection should have been made) or when one specifies > a remote image as path and wants to display it inline. > Perhaps I could add an option flag or ask a question before fetching for > user to decide whether to display remote images or not? In case the > behaviour of displaying remote images inline is not desired? One scenario > I can think of is that `org-startup-with-inline-images' is set to true and > the file is sometimes visited remotely. > Any opinion or comment on this, please? > > >> - (let ((file (expand-file-name (org-element-property :path > link)))) > >> + (let ((file (substitute-in-file-name (expand-file-name > (org-element-property :path link))))) > > Why is it needed? > > Because the file path for a remote file, as far as I have tested, have > redundant slashes "/" at the beginning of the path which makes > org-file-remote-p to return nil for a remote path. > `substitute-in-file-name' corrects such path. `substitute-in-file-name' > is also used in `org-open-file'. So I followed suit. > > > Are you sure the return value (a boolean, i.e., not necessarily > > a string) should belong to the `concat'? > > Good point. I changed the code (see below, and attached). > > > (create-image (if (org-file-remote-p file) ...) > > (and width 'imagemagick) > > nil > > :width width) > > I agree. Thanks. I made the code cleaner now (see below, and attached). > > > @@ -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,24 @@ 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")) > + (newname (concat > + tramp-tmpdir > + (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 > > > > On Tue, Nov 25, 2014 at 3:32 AM, Nicolas Goaziou > wrote: > >> Hello, >> >> Kit-Yan Choi writes: >> >> > 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 >> > >> > .) >> >> Thanks for your patch. However, I wonder if we really want this. Remote >> images could be slow to fetch, and it would make buffer unusable. >> >> > Feedbacks are most welcome. Thanks. >> >> Some comments follow. >> >> > - (let ((file (expand-file-name (org-element-property :path >> link)))) >> > + (let ((file (substitute-in-file-name (expand-file-name >> (org-element-property :path link))))) >> >> Why is it needed? >> >> > + (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) >> >> ^^^^^^^^^^^^^^^^^^^^^^^^ >> Are you sure the return value (a boolean, i.e., not necessarily >> a string) should belong to the `concat'? >> >> > + >> (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)))) >> >> IMO, it is clearer to use >> >> (create-image (if (org-file-remote-p file) ...) >> (and width 'imagemagick) >> nil >> :width width) >> >> >> >> Regards, >> >> -- >> Nicolas Goaziou >> > > --001a11349f2e147d100508b094f1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Ah my apologies.=C2=A0 I forgot I had to use `file-name-di= rectory' for creating the path to the temporary directory (too long ago= since I did this).=C2=A0 Here is the corrected version.

--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19340,7 += 19340,7 @@ boundaries."
=C2=A0 =C2=A0 =C2=A0(not (cdr (org-element-contents parent= )))))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0(org-string-match-p file-extension-re
=C2=A0<= span class=3D"" style=3D"white-space:pre"> =C2=A0(org-element-p= roperty :path link)))
- =C2=A0 =C2=A0 (let ((file (expand-file-name (org-element-property= :path link))))
+ =C2=A0 =C2=A0 (let ((file (substitute-in-file-name (expand-file-name (o= rg-element-property :path link)))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (file-exists-p fil= e)
=C2=A0 (le= t ((width
=C2=A0 ;; Apply `org-image-actual-width' specifications.
@@ -193= 78,10 +19378,25 @@ boundaries."
=C2=A0 =C2=A0 =C2=A0 'org-image-overlay)))
=C2=A0 =C2=A0 (i= f (and (car-safe old) refresh)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (image-refresh (overlay-get (= cdr old) 'display))
- =C2=A0 =C2=A0 (let ((image (create-image file
- =C2=A0(and width 'i= magemagick)
- =C2=A0nil
- = =C2=A0:width width)))
+ =C2=A0 =C2=A0 (let ((image=C2=A0
+ =C2=A0 =C2=A0(create-image (if (= org-file-remote-p file)
+ =C2=A0 =C2=A0 =C2=A0(let* ((tramp-tmpdir (concat
= + =C2=A0 =C2=A0(i= f (featurep 'xemacs)
+ (temp-directory)
+ =C2=A0 =C2=A0 =C2=A0temporary-file-director= y)
+ = =C2=A0 =C2=A0"/tramp"
+ =C2=A0 =C2=A0(file-name-directory (expand-file-n= ame file))))
+ =C2=A0 =C2=A0 (newname (concat
+ =C2=A0 =C2=A0 =C2=A0 tramp-tmpdir=C2=A0
+ =C2=A0 =C2= =A0 =C2=A0 (file-name-nondirectory (expand-file-name file)))))
+<= span class=3D"" style=3D"white-space:pre"> (make-directory tram= p-tmpdir t)
+ (if (file-newer-than-file-p file newname)
+ =C2=A0 =C2=A0(copy-file file newname= t t))
+ n= ewname)
+ = =C2=A0 =C2=A0file)
+ = =C2=A0(and width 'imagemagick)
+ =C2=A0nil
+ =C2=A0:width width)))
=C2= =A0 =C2=A0 =C2=A0 =C2= =A0 (when image
=C2=A0= (let* ((link
=C2=A0 ;; If inline image is the description
<= br>

On= Tue, Nov 25, 2014 at 10:15 AM, Kit-Yan Choi <kit@kychoi.org> = wrote:
Thank you for you= r comments!=C2=A0 They are very helpful.

> Thanks for your patch. However, I wonder if we really want this. Rem= ote
> images could be slow to fetch, and it would make buffer unusa= ble.

I personally needed this functionality.= =C2=A0 I have tried to reduce the amount of time spent on fetching the imag= es by checking whether the images have been fetched before and whether the = remote files are newer.=C2=A0 Yes these communications take time as it shou= ld be expected if one opens an org file remotely (therefore connection shou= ld have been made) or when one specifies a remote image as path and wants t= o display it inline.
Perhaps I could add an option flag or ask a = question before fetching for user to decide whether to display remote image= s or not?=C2=A0 In case the behaviour of displaying remote images inline is= not desired?=C2=A0 One scenario I can think of is that `org-startup-with-i= nline-images' is set to true and the file is sometimes visited remotely= . =C2=A0
Any opinion or comment on this, please?

>> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let= ((file (expand-file-name (org-element-property :path link))))
>> = +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((file (substitute-in-file-name (e= xpand-file-name (org-element-property :path link)))))
> Why is it nee= ded?

Because the file path for a remote fil= e, as far as I have tested, have redundant slashes "/" at the beg= inning of the path which makes org-file-remote-p to return nil for a remote= path.
`substitute-in-file-name' corrects such path. =C2=A0`s= ubstitute-in-file-name' is also used in `org-open-file'.=C2=A0 So I= followed suit.

> Are you sure= the return value (a boolean, i.e., not necessarily
> a string) sho= uld belong to the `concat'?

Good point.=C2=A0= I changed the code (see below, and attached).
<= br>
> =C2=A0(create-image (if (org-file-remote-p file) ...)> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(and width &= #39;imagemagick)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0nil
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:w= idth width)

I agree.=C2=A0 Thanks.=C2=A0 I made t= he code cleaner now (see below, and attached).


@@ -19340,7 +19340,7 @@ boundaries."
=C2=A0 <= /span> =C2=A0 =C2=A0(not (cdr (org-element-contents parent)))))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0(org-string-match-p file-extension-re
=C2=A0 = =C2=A0(org-element-property :path link)))
- =C2=A0 =C2= =A0 (let ((file (expand-file-name (org-element-property :path link))))
+ = =C2=A0 =C2=A0 (let ((file (substitute-in-file-name (expand-file-name (org-e= lement-property :path link)))))
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 (when= (file-exists-p file)
=C2=A0 (let ((width
=C2=A0 ;; Apply `org-image-= actual-width' specifications.
@@ -19378= ,10 +19378,24 @@ boundaries."
=C2=A0 =C2=A0 =C2=A0 'org-image-= overlay)))
=C2=A0 =C2=A0 (if (and (car-safe old) refresh)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 (image-refresh (overlay-get (cdr old) 'display))
- = =C2=A0 =C2=A0 (let ((image (create-image file
- =C2=A0(and width &#= 39;imagemagick)
- =C2=A0nil
- =C2=A0:width width)))
+ =C2= =A0 =C2=A0 (let ((image=C2=A0
+ =C2=A0 =C2=A0(create-image (if (org-fi= le-remote-p file)
+ =C2=A0 =C2=A0 =C2=A0(let* ((tram= p-tmpdir (concat
+ =C2=A0 =C2=A0(if (featurep 'xemacs)
+ (temp-directory)
+ =C2=A0 =C2=A0 =C2=A0temporary-file-director= y)
+ =C2=A0 =C2=A0"/tramp"))
+ =C2=A0 =C2=A0 (newname (concat
+ =C2=A0 =C2=A0 =C2=A0 tramp-t= mpdir=C2=A0
+ =C2=A0 =C2=A0 =C2=A0 (expand-file-name file)))= )
+ = (make-directory tramp-tmpdir t)
+= (if (file-newer-than-file= -p file newname)
+ =C2=A0 =C2=A0(copy-file file newname t t))
<= div class=3D"gmail_extra">+ newname)
+ =C2=A0 =C2=A0file)
+ =C2=A0(and w= idth 'imagemagick)
+ =C2=A0nil
+<= span style=3D"white-space:pre-wrap"> =C2=A0:width width)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (when image
=C2=A0 (let* ((link
=
=C2=A0 <= /span> ;; If inline image is the description



On Tue, Nov 25, 2014 at 3:32 A= M, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;pa= dding-left:1ex">Hello,

Kit-Yan Choi <kit@ky= choi.org> writes:

> I would like to submit a patch to support displaying remote images inl= ine
> in Org-mode.=C2=A0 Attached is the formatted patch (or github branch h= ere
> <https://github.com/k= itchoi/org-mode/commit/2e600da455c371754f028ddaaed1ae1724cbe6b6>
> .)

Thanks for your patch. However, I wonder if we really want this. Remote
images could be slow to fetch, and it would make buffer unusable.

> Feedbacks are most welcome.=C2=A0 Thanks.

Some comments follow.

> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((file (expand-file-name (org= -element-property :path link))))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let ((file (substitute-in-file-na= me (expand-file-name (org-element-property :path link)))))

Why is it needed?

> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (let* = ((image
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 (let ((newname
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (org-file-remote-p fil= e)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let* ((tram= p-tmpdir (concat
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (feat= urep 'xemacs)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=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^^^^^^^^^
Are you sure the return value (a boolean, i.e., not necessarily
a string) should belong to the `concat'?

> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(file-nam= e-directory
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-bab= el-local-file-name file))))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (newname (concat
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 tramp-tmpdir
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (file-name-nondirectory file)= )))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(make= -directory tramp-tmpdir t)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (= tramp-handle-file-newer-than-file-p file newname)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(tramp-compat-copy-file file newname t t))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0newna= me)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0file)))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 (create-image newname
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (and width 'imagemagick)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 nil
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 :width width))))

IMO, it is clearer to use

=C2=A0 (create-image (if (org-file-remote-p file) ...)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (and width 'ima= gemagick)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 nil
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :width width)



Regards,

--
Nicolas Goaziou


--001a11349f2e147d100508b094f1-- --001a11349f2e147d160508b094f3 Content-Type: text/plain; charset=US-ASCII; name="0001-org.el.diff" Content-Disposition: attachment; filename="0001-org.el.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i2xf5hy01 ZGlmZiAtLWdpdCBhL2xpc3Avb3JnLmVsIGIvbGlzcC9vcmcuZWwKaW5kZXggNmFiMTNmNC4uNDRj YTdkNiAxMDA3NTUKLS0tIGEvbGlzcC9vcmcuZWwKKysrIGIvbGlzcC9vcmcuZWwKQEAgLTE5MzQw LDcgKzE5MzQwLDcgQEAgYm91bmRhcmllcy4iCiAJCQkgICAgKG5vdCAoY2RyIChvcmctZWxlbWVu dC1jb250ZW50cyBwYXJlbnQpKSkpKQogCQkg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