emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: Re: Wow -- adding images to an org file
@ 2010-05-11 23:20 robut
  2010-05-12  5:35 ` [PATCH] " Baoqiu Cui
  2010-05-12  5:39 ` Baoqiu Cui
  0 siblings, 2 replies; 7+ messages in thread
From: robut @ 2010-05-11 23:20 UTC (permalink / raw)
  To: emacs-orgmode, Dan Davison

[-- Attachment #1: Type: text/html, Size: 6564 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* [PATCH] Re: Wow -- adding images to an org file
  2010-05-11 23:20 Re: Wow -- adding images to an org file robut
@ 2010-05-12  5:35 ` Baoqiu Cui
  2010-05-12  5:39 ` Baoqiu Cui
  1 sibling, 0 replies; 7+ messages in thread
From: Baoqiu Cui @ 2010-05-12  5:35 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]

"robut@iinet.net.au" <robut@iinet.net.au> writes:

> I very much like the idea of native inline image display in Org-mode but  can't
> seem to make it work.
>
> Given a 6.36 snapshot or 6.36 release and these org file contents
>
> * Test image
> Test image
> [[Screenshot.png]]
>
>
> I hoped org would display that image after C-c C-x C-v. Rather Org-mode returns
> "No images to display inline".
>
> I've tried different ways of linking that image, different image formats,
> relative vs complete paths, and my regular .emacs vs  a near empty one and
> always the same result. If I toggle iimage-mode the image displays fine per se
> but does not affect how Org-mode works.
>
> Seems clear I am missing something simple. What?

I like the idea of inline image display too, but hit the similar
problems.  After reading the code in org.el, I found that the inline
image file link has to start with either "file:" or "./".

For example, the following two links are OK:

   [[file:~/images/myImage.png]]
   [[./figures/org-mode-unicorn.svg]]

but the following two are not:

   [[Screenshot.png]]
   [[~/images/myImage.png]]

Here is a small patch that seems to work well for me, but I'd like
Carsten to check whether it may break anything:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: inline-images.diff --]
[-- Type: text/x-patch, Size: 500 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 0381a26..5efc162 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15502,7 +15502,7 @@ with a description part will be inlined."
   (interactive "P")
   (org-remove-inline-images)
   (goto-char (point-min))
-  (let ((re (concat "\\[\\[\\(file:\\|\\./\\)\\(~?" "[-+./_0-9a-zA-Z]+"
+  (let ((re (concat "\\[\\[\\(file:\\)?\\(~?" "[-+./_0-9a-zA-Z]+"
 		    (substring (org-image-file-name-regexp) 0 -2)
 		    "\\)\\]" (if include-linked "" "\\]")))
 	file ov)

[-- Attachment #3: Type: text/plain, Size: 22 bytes --]


Regards,

-- 
Baoqiu

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Wow -- adding images to an org file
  2010-05-11 23:20 Re: Wow -- adding images to an org file robut
  2010-05-12  5:35 ` [PATCH] " Baoqiu Cui
@ 2010-05-12  5:39 ` Baoqiu Cui
  2010-05-12  6:07   ` Carsten Dominik
  1 sibling, 1 reply; 7+ messages in thread
From: Baoqiu Cui @ 2010-05-12  5:39 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]

"robut@iinet.net.au" <robut@iinet.net.au> writes:

> I very much like the idea of native inline image display in Org-mode but  can't
> seem to make it work.
>
> Given a 6.36 snapshot or 6.36 release and these org file contents
>
> * Test image
> Test image
> [[Screenshot.png]]
>
>
> I hoped org would display that image after C-c C-x C-v. Rather Org-mode returns
> "No images to display inline".
>
> I've tried different ways of linking that image, different image formats,
> relative vs complete paths, and my regular .emacs vs  a near empty one and
> always the same result. If I toggle iimage-mode the image displays fine per se
> but does not affect how Org-mode works.
>
> Seems clear I am missing something simple. What?

I like the idea of inline image display too, but hit the similar
problems.  After reading the code in org.el, I found that the inline
image file link has to start with either "file:" or "./".

For example, the following two links are OK:

   [[file:~/images/myImage.png]]
   [[./figures/org-mode-unicorn.svg]]

but the following two are not:

   [[Screenshot.png]]
   [[~/images/myImage.png]]

Here is a small patch that seems to work well for me, but I'd like
Carsten to check whether it may break anything:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: inline-images.diff --]
[-- Type: text/x-patch, Size: 500 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 0381a26..5efc162 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15502,7 +15502,7 @@ with a description part will be inlined."
   (interactive "P")
   (org-remove-inline-images)
   (goto-char (point-min))
-  (let ((re (concat "\\[\\[\\(file:\\|\\./\\)\\(~?" "[-+./_0-9a-zA-Z]+"
+  (let ((re (concat "\\[\\[\\(file:\\)?\\(~?" "[-+./_0-9a-zA-Z]+"
 		    (substring (org-image-file-name-regexp) 0 -2)
 		    "\\)\\]" (if include-linked "" "\\]")))
 	file ov)

[-- Attachment #3: Type: text/plain, Size: 22 bytes --]


Regards,

-- 
Baoqiu

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Re: Wow -- adding images to an org file
  2010-05-12  5:39 ` Baoqiu Cui
@ 2010-05-12  6:07   ` Carsten Dominik
  2010-05-12  7:55     ` Baoqiu Cui
  0 siblings, 1 reply; 7+ messages in thread
From: Carsten Dominik @ 2010-05-12  6:07 UTC (permalink / raw)
  To: Baoqiu Cui; +Cc: emacs-orgmode


On May 12, 2010, at 7:39 AM, Baoqiu Cui wrote:

> "robut@iinet.net.au" <robut@iinet.net.au> writes:
>
>> I very much like the idea of native inline image display in Org- 
>> mode but  can't
>> seem to make it work.
>>
>> Given a 6.36 snapshot or 6.36 release and these org file contents
>>
>> * Test image
>> Test image
>> [[Screenshot.png]]
>>
>>
>> I hoped org would display that image after C-c C-x C-v. Rather Org- 
>> mode returns
>> "No images to display inline".
>>
>> I've tried different ways of linking that image, different image  
>> formats,
>> relative vs complete paths, and my regular .emacs vs  a near empty  
>> one and
>> always the same result. If I toggle iimage-mode the image displays  
>> fine per se
>> but does not affect how Org-mode works.
>>
>> Seems clear I am missing something simple. What?
>
> I like the idea of inline image display too, but hit the similar
> problems.  After reading the code in org.el, I found that the inline
> image file link has to start with either "file:" or "./".
>
> For example, the following two links are OK:
>
>   [[file:~/images/myImage.png]]
>   [[./figures/org-mode-unicorn.svg]]
>
> but the following two are not:
>
>   [[Screenshot.png]]

This one I do not want to support, because it limits what other things  
we
can do with links.

>   [[~/images/myImage.png]]

This one on the other hand should be supported, I like that.  Can you  
please modify the patch accordingly?  I believe this will also require  
corresponding changes in the exporter(s) somewhere...

Thanks!

- Carsten

>
> Here is a small patch that seems to work well for me, but I'd like
> Carsten to check whether it may break anything:
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 0381a26..5efc162 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -15502,7 +15502,7 @@ with a description part will be inlined."
>   (interactive "P")
>   (org-remove-inline-images)
>   (goto-char (point-min))
> -  (let ((re (concat "\\[\\[\\(file:\\|\\./\\)\\(~?" "[-+./_0-9a-zA- 
> Z]+"
> +  (let ((re (concat "\\[\\[\\(file:\\)?\\(~?" "[-+./_0-9a-zA-Z]+"
> 		    (substring (org-image-file-name-regexp) 0 -2)
> 		    "\\)\\]" (if include-linked "" "\\]")))
> 	file ov)
>
> Regards,
>
> -- 
> Baoqiu
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

* Re: Wow -- adding images to an org file
  2010-05-12  6:07   ` Carsten Dominik
@ 2010-05-12  7:55     ` Baoqiu Cui
  2010-05-12 12:48       ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Baoqiu Cui @ 2010-05-12  7:55 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

Hi Carsten,

Carsten Dominik <carsten.dominik@gmail.com> writes:

> On May 12, 2010, at 7:39 AM, Baoqiu Cui wrote:
>
> ...
>
>> I like the idea of inline image display too, but hit the similar
>> problems.  After reading the code in org.el, I found that the inline
>> image file link has to start with either "file:" or "./".
>>
>> For example, the following two links are OK:
>>
>>   [[file:~/images/myImage.png]]
>>   [[./figures/org-mode-unicorn.svg]]
>>
>> but the following two are not:
>>
>>   [[Screenshot.png]]
>
> This one I do not want to support, because it limits what other things
> we
> can do with links.
>
>>   [[~/images/myImage.png]]
>
> This one on the other hand should be supported, I like that.  Can you
> please modify the patch accordingly?  I believe this will also require
> corresponding changes in the exporter(s) somewhere...

OK, I modified the patch a little bit and came up with a version (see
below) that can handle the following 7 cases.  Please check if it looks
good to you.  I don't see any needed exporter changes so far...

------------------------------------------------------------------------
* Test Inline Images

1. [[file:~/Org/GNU.png]]
2. [[file:GNU.png]]
3. [[./figures/GNU.png]]
4. [[../tmp/figures/GNU.png]]
5. [[~/Org/GNU.png]]
6. [[~bcui/Org/GNU.png]]
7. [[/tmp/GNU.png]]
------------------------------------------------------------------------


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: inline-images-2.diff --]
[-- Type: text/x-patch, Size: 854 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 0381a26..51230b3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15502,12 +15502,14 @@ with a description part will be inlined."
   (interactive "P")
   (org-remove-inline-images)
   (goto-char (point-min))
-  (let ((re (concat "\\[\\[\\(file:\\|\\./\\)\\(~?" "[-+./_0-9a-zA-Z]+"
+  (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([-+~./_0-9a-zA-Z]+"
 		    (substring (org-image-file-name-regexp) 0 -2)
 		    "\\)\\]" (if include-linked "" "\\]")))
 	file ov)
   (while (re-search-forward re nil t)
-    (setq file (expand-file-name (match-string 2)))
+    (setq file (expand-file-name
+		(concat (or (match-string 3) "")
+			(match-string 4))))
     (when (file-exists-p file)
       (setq ov (make-overlay (match-beginning 0) (match-end 0)))
       (overlay-put ov 'display (create-image file))

[-- Attachment #3: Type: text/plain, Size: 21 bytes --]


Thanks,

-- 
Baoqiu

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: Re: Wow -- adding images to an org file
  2010-05-12  7:55     ` Baoqiu Cui
@ 2010-05-12 12:48       ` Carsten Dominik
  2010-05-12 16:36         ` Baoqiu Cui
  0 siblings, 1 reply; 7+ messages in thread
From: Carsten Dominik @ 2010-05-12 12:48 UTC (permalink / raw)
  To: Baoqiu Cui; +Cc: emacs-orgmode

Hi Baoqiu,

thanks for the patch, I have applied it.  Hopefully this will work in  
the
export backends, but it might - otherwise we will see bug reports soon  
enough...

- Carsten


On May 12, 2010, at 9:55 AM, Baoqiu Cui wrote:

> Hi Carsten,
>
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> On May 12, 2010, at 7:39 AM, Baoqiu Cui wrote:
>>
>> ...
>>
>>> I like the idea of inline image display too, but hit the similar
>>> problems.  After reading the code in org.el, I found that the inline
>>> image file link has to start with either "file:" or "./".
>>>
>>> For example, the following two links are OK:
>>>
>>>  [[file:~/images/myImage.png]]
>>>  [[./figures/org-mode-unicorn.svg]]
>>>
>>> but the following two are not:
>>>
>>>  [[Screenshot.png]]
>>
>> This one I do not want to support, because it limits what other  
>> things
>> we
>> can do with links.
>>
>>>  [[~/images/myImage.png]]
>>
>> This one on the other hand should be supported, I like that.  Can you
>> please modify the patch accordingly?  I believe this will also  
>> require
>> corresponding changes in the exporter(s) somewhere...
>
> OK, I modified the patch a little bit and came up with a version (see
> below) that can handle the following 7 cases.  Please check if it  
> looks
> good to you.  I don't see any needed exporter changes so far...
>
> ------------------------------------------------------------------------
> * Test Inline Images
>
> 1. [[file:~/Org/GNU.png]]
> 2. [[file:GNU.png]]
> 3. [[./figures/GNU.png]]
> 4. [[../tmp/figures/GNU.png]]
> 5. [[~/Org/GNU.png]]
> 6. [[~bcui/Org/GNU.png]]
> 7. [[/tmp/GNU.png]]
> ------------------------------------------------------------------------
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 0381a26..51230b3 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -15502,12 +15502,14 @@ with a description part will be inlined."
>   (interactive "P")
>   (org-remove-inline-images)
>   (goto-char (point-min))
> -  (let ((re (concat "\\[\\[\\(file:\\|\\./\\)\\(~?" "[-+./_0-9a-zA- 
> Z]+"
> +  (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([-+~./ 
> _0-9a-zA-Z]+"
> 		    (substring (org-image-file-name-regexp) 0 -2)
> 		    "\\)\\]" (if include-linked "" "\\]")))
> 	file ov)
>   (while (re-search-forward re nil t)
> -    (setq file (expand-file-name (match-string 2)))
> +    (setq file (expand-file-name
> +		(concat (or (match-string 3) "")
> +			(match-string 4))))
>     (when (file-exists-p file)
>       (setq ov (make-overlay (match-beginning 0) (match-end 0)))
>       (overlay-put ov 'display (create-image file))
>
> Thanks,
>
> -- 
> Baoqiu
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

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

* Re: Wow -- adding images to an org file
  2010-05-12 12:48       ` Carsten Dominik
@ 2010-05-12 16:36         ` Baoqiu Cui
  0 siblings, 0 replies; 7+ messages in thread
From: Baoqiu Cui @ 2010-05-12 16:36 UTC (permalink / raw)
  To: emacs-orgmode

Carsten Dominik <carsten.dominik@gmail.com> writes:

> Hi Baoqiu,
>
> thanks for the patch, I have applied it.  Hopefully this will work in
> the
> export backends, but it might - otherwise we will see bug reports soon
> enough...

Thanks, Carsten.  I have tried my test case for LaTeX, DocBook, and HTML
exporters and everything seemed to work.

-- 
Baoqiu

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

end of thread, other threads:[~2010-05-12 16:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-11 23:20 Re: Wow -- adding images to an org file robut
2010-05-12  5:35 ` [PATCH] " Baoqiu Cui
2010-05-12  5:39 ` Baoqiu Cui
2010-05-12  6:07   ` Carsten Dominik
2010-05-12  7:55     ` Baoqiu Cui
2010-05-12 12:48       ` Carsten Dominik
2010-05-12 16:36         ` Baoqiu Cui

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