emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: Re: Wow -- adding images to an org file
  2010-05-07  2:16 ` Chris Thompson
@ 2010-05-07  7:55   ` Carsten Dominik
  2010-05-07 12:58     ` Dan Davison
  0 siblings, 1 reply; 14+ messages in thread
From: Carsten Dominik @ 2010-05-07  7:55 UTC (permalink / raw)
  To: Chris Thompson; +Cc: emacs-orgmode


On May 7, 2010, at 4:16 AM, Chris Thompson wrote:

> Nathan Neff <nathan.neff <at> gmail.com> writes:
>
>>
>> I just saw Andreas's screenshot here:
>>
>> http://orgmode.org/worg/org-screenshots.php
>>
>> If you zoom in to his screenshot,
>> http://orgmode.org/img/screenshots/org_andreas.jpg
>>
>> You can see how he adds images to his org files.
>> All that I had to do was put this into my emacs init file:
>>
>> (defun org-dblock-write:image (params)
>>  (let ((file (plist-get params :file)))
>>     (clear-image-cache file)
>>     (insert-image (create-image file) )))
>>
>> Then, put this in an org-file:
>>
>> #+BEGIN: image :file "~/Documents/personal/foo.png"
>> #+END
>>
>> And run C-c C-c (or is it C-c C-x C-u)?
>>
>> Anyway, Cool stuff!
>>
>> --Nate
>>
>
>
> Another way to have images in org-mode documents is to use the  
> "iimage"
> minor mode, which handles  inline images:
> http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html
>
> For additional documentation:
> http://orgmode.org/worg/org-configs/org-config-examples.php#sec-2_2

At that place, I find this code:
(add-to-list 'iimage-mode-image-regex-alist (cons (concat "\\[\\[file:\ 
\(~?" iimage-mode-image-filename-regex "\\)\\]") 1))
  (defun org-toggle-iimage-in-org () "display images in your org  
file" (interactive) (if (face-underline-p 'org-link) (set-face- 
underline-p 'org-link nil) (set-face-underline-p 'org-link t)) (iimage- 
mode))
I guess I could actually add the above code to org.el, so that the  
only thing to do for a user would be to turn on iimage-mode.
What is the purpose of toggling the underline property of the link face?

- Carsten

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

* Re: Re: Wow -- adding images to an org file
  2010-05-07  7:55   ` Carsten Dominik
@ 2010-05-07 12:58     ` Dan Davison
  2010-05-08 10:51       ` Carsten Dominik
  0 siblings, 1 reply; 14+ messages in thread
From: Dan Davison @ 2010-05-07 12:58 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, Chris Thompson

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

> On May 7, 2010, at 4:16 AM, Chris Thompson wrote:
>
>> Nathan Neff <nathan.neff <at> gmail.com> writes:
>>
>>>
>>> I just saw Andreas's screenshot here:
>>>
>>> http://orgmode.org/worg/org-screenshots.php
>>>
>>> If you zoom in to his screenshot,
>>> http://orgmode.org/img/screenshots/org_andreas.jpg
>>>
>>> You can see how he adds images to his org files.
>>> All that I had to do was put this into my emacs init file:
>>>
>>> (defun org-dblock-write:image (params)
>>>  (let ((file (plist-get params :file)))
>>>     (clear-image-cache file)
>>>     (insert-image (create-image file) )))
>>>
>>> Then, put this in an org-file:
>>>
>>> #+BEGIN: image :file "~/Documents/personal/foo.png"
>>> #+END
>>>
>>> And run C-c C-c (or is it C-c C-x C-u)?
>>>
>>> Anyway, Cool stuff!
>>>
>>> --Nate
>>>
>>
>>
>> Another way to have images in org-mode documents is to use the
>> "iimage"
>> minor mode, which handles  inline images:
>> http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html
>>
>> For additional documentation:
>> http://orgmode.org/worg/org-configs/org-config-examples.php#sec-2_2
>
> At that place, I find this code:
> (add-to-list 'iimage-mode-image-regex-alist (cons (concat
> "\\[\\[file:\
> \(~?" iimage-mode-image-filename-regex "\\)\\]") 1))
>  (defun org-toggle-iimage-in-org () "display images in your org file"
> (interactive) (if (face-underline-p 'org-link) (set-face- 
> underline-p 'org-link nil) (set-face-underline-p 'org-link t))
> (iimage-
> mode))
> I guess I could actually add the above code to org.el, so that the
> only thing to do for a user would be to turn on iimage-mode.
> What is the purpose of toggling the underline property of the link face?

It puts a horizontal line through the middle of the displayed image
(haven't checked if that's fixed in latest emacs).

Dan


>
> - Carsten
>
>
>
> _______________________________________________
> 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] 14+ messages in thread

* Re: Re: Wow -- adding images to an org file
  2010-05-07 12:58     ` Dan Davison
@ 2010-05-08 10:51       ` Carsten Dominik
  2010-05-09 15:05         ` Daniel Martins
  2010-05-11 19:14         ` Russell Adams
  0 siblings, 2 replies; 14+ messages in thread
From: Carsten Dominik @ 2010-05-08 10:51 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode, Chris Thompson


On May 7, 2010, at 2:58 PM, Dan Davison wrote:

> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> On May 7, 2010, at 4:16 AM, Chris Thompson wrote:
>>
>>> Nathan Neff <nathan.neff <at> gmail.com> writes:
>>>
>>>>
>>>> I just saw Andreas's screenshot here:
>>>>
>>>> http://orgmode.org/worg/org-screenshots.php
>>>>
>>>> If you zoom in to his screenshot,
>>>> http://orgmode.org/img/screenshots/org_andreas.jpg
>>>>
>>>> You can see how he adds images to his org files.
>>>> All that I had to do was put this into my emacs init file:
>>>>
>>>> (defun org-dblock-write:image (params)
>>>> (let ((file (plist-get params :file)))
>>>>    (clear-image-cache file)
>>>>    (insert-image (create-image file) )))
>>>>
>>>> Then, put this in an org-file:
>>>>
>>>> #+BEGIN: image :file "~/Documents/personal/foo.png"
>>>> #+END
>>>>
>>>> And run C-c C-c (or is it C-c C-x C-u)?
>>>>
>>>> Anyway, Cool stuff!
>>>>
>>>> --Nate
>>>>
>>>
>>>
>>> Another way to have images in org-mode documents is to use the
>>> "iimage"
>>> minor mode, which handles  inline images:
>>> http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html
>>>
>>> For additional documentation:
>>> http://orgmode.org/worg/org-configs/org-config-examples.php#sec-2_2
>>
>> At that place, I find this code:
>> (add-to-list 'iimage-mode-image-regex-alist (cons (concat
>> "\\[\\[file:\
>> \(~?" iimage-mode-image-filename-regex "\\)\\]") 1))
>> (defun org-toggle-iimage-in-org () "display images in your org file"
>> (interactive) (if (face-underline-p 'org-link) (set-face-
>> underline-p 'org-link nil) (set-face-underline-p 'org-link t))
>> (iimage-
>> mode))
>> I guess I could actually add the above code to org.el, so that the
>> only thing to do for a user would be to turn on iimage-mode.
>> What is the purpose of toggling the underline property of the link  
>> face?
>
> It puts a horizontal line through the middle of the displayed image
> (haven't checked if that's fixed in latest emacs).

I see.

We have now native inline image display in Org-mode, you can toggle it  
with

C-c C-x C-v

This implementation uses overlays instead of text properties and  
therefore does not interfere with font-lock.

- Carsten

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

* Re: Re: Wow -- adding images to an org file
  2010-05-08 10:51       ` Carsten Dominik
@ 2010-05-09 15:05         ` Daniel Martins
  2010-05-09 17:23           ` Sebastian Rose
  2010-05-11 19:14         ` Russell Adams
  1 sibling, 1 reply; 14+ messages in thread
From: Daniel Martins @ 2010-05-09 15:05 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Dan Davison, Chris Thompson, emacs-orgmode


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

In short

What I have to do (minimal code in .emacs and .org) to display an image?


This image will be maintained when I export the file?

iimage could be included in org distribution?



Daniel


2010/5/8 Carsten Dominik <carsten.dominik@gmail.com>

>
> On May 7, 2010, at 2:58 PM, Dan Davison wrote:
>
>  Carsten Dominik <carsten.dominik@gmail.com> writes:
>>
>>  On May 7, 2010, at 4:16 AM, Chris Thompson wrote:
>>>
>>>  Nathan Neff <nathan.neff <at> gmail.com> writes:
>>>>
>>>>
>>>>> I just saw Andreas's screenshot here:
>>>>>
>>>>> http://orgmode.org/worg/org-screenshots.php
>>>>>
>>>>> If you zoom in to his screenshot,
>>>>> http://orgmode.org/img/screenshots/org_andreas.jpg
>>>>>
>>>>> You can see how he adds images to his org files.
>>>>> All that I had to do was put this into my emacs init file:
>>>>>
>>>>> (defun org-dblock-write:image (params)
>>>>> (let ((file (plist-get params :file)))
>>>>>   (clear-image-cache file)
>>>>>   (insert-image (create-image file) )))
>>>>>
>>>>> Then, put this in an org-file:
>>>>>
>>>>> #+BEGIN: image :file "~/Documents/personal/foo.png"
>>>>> #+END
>>>>>
>>>>> And run C-c C-c (or is it C-c C-x C-u)?
>>>>>
>>>>> Anyway, Cool stuff!
>>>>>
>>>>> --Nate
>>>>>
>>>>>
>>>>
>>>> Another way to have images in org-mode documents is to use the
>>>> "iimage"
>>>> minor mode, which handles  inline images:
>>>> http://www.netlaputa.ne.jp/~kose/Emacs/iimage.html<http://www.netlaputa.ne.jp/%7Ekose/Emacs/iimage.html>
>>>>
>>>> For additional documentation:
>>>> http://orgmode.org/worg/org-configs/org-config-examples.php#sec-2_2
>>>>
>>>
>>> At that place, I find this code:
>>> (add-to-list 'iimage-mode-image-regex-alist (cons (concat
>>> "\\[\\[file:\
>>> \(~?" iimage-mode-image-filename-regex "\\)\\]") 1))
>>> (defun org-toggle-iimage-in-org () "display images in your org file"
>>> (interactive) (if (face-underline-p 'org-link) (set-face-
>>> underline-p 'org-link nil) (set-face-underline-p 'org-link t))
>>> (iimage-
>>> mode))
>>> I guess I could actually add the above code to org.el, so that the
>>> only thing to do for a user would be to turn on iimage-mode.
>>> What is the purpose of toggling the underline property of the link face?
>>>
>>
>> It puts a horizontal line through the middle of the displayed image
>> (haven't checked if that's fixed in latest emacs).
>>
>
> I see.
>
> We have now native inline image display in Org-mode, you can toggle it with
>
> C-c C-x C-v
>
> This implementation uses overlays instead of text properties and therefore
> does not interfere with font-lock.
>
>
> - Carsten
>
>
>
> _______________________________________________
> 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
>

[-- Attachment #1.2: Type: text/html, Size: 4477 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] 14+ messages in thread

* Re: Re: Wow -- adding images to an org file
  2010-05-09 15:05         ` Daniel Martins
@ 2010-05-09 17:23           ` Sebastian Rose
  0 siblings, 0 replies; 14+ messages in thread
From: Sebastian Rose @ 2010-05-09 17:23 UTC (permalink / raw)
  To: Daniel Martins
  Cc: Dan Davison, emacs-orgmode, Chris Thompson, Carsten Dominik

Daniel Martins <danielemc@gmail.com> writes:
> In short
>
> What I have to do (minimal code in .emacs and .org) to display an image?


Update to current Org-Mode and from the on press


    C-c C-x C-v

> This image will be maintained when I export the file?

Yes.

> iimage could be included in org distribution?

Not neccessary anymore.




> 2010/5/8 Carsten Dominik <carsten.dominik@gmail.com>
>>  ....

>> We have now native inline image display in Org-mode, you can toggle it with
>>
>> C-c C-x C-v
>>
>> This implementation uses overlays instead of text properties and therefore
>> does not interfere with font-lock.
>>
>>
>> - Carsten



  Sebastian

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

* Re: Re: Wow -- adding images to an org file
  2010-05-08 10:51       ` Carsten Dominik
  2010-05-09 15:05         ` Daniel Martins
@ 2010-05-11 19:14         ` Russell Adams
  2010-05-11 21:29           ` Dan Davison
  1 sibling, 1 reply; 14+ messages in thread
From: Russell Adams @ 2010-05-11 19:14 UTC (permalink / raw)
  To: emacs-orgmode

On Sat, May 08, 2010 at 12:51:41PM +0200, Carsten Dominik wrote:
> We have now native inline image display in Org-mode, you can toggle it  
> with
>
> C-c C-x C-v
>
> This implementation uses overlays instead of text properties and  
> therefore does not interfere with font-lock.
>
> - Carsten

I'm using Org-Babel and R, and when I use C-c C-c to update the output
from a block of code, the image in emacs doesn't change.

Ideas? v6.36

Thanks.

------------------------------------------------------------------
Russell Adams                            RLAdams@AdamsInfoServ.com

PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3

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

* 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; 14+ 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ messages in thread

* Re: Re: Wow -- adding images to an org file
  2010-05-11 21:29           ` Dan Davison
@ 2010-05-12 12:41             ` Carsten Dominik
  0 siblings, 0 replies; 14+ messages in thread
From: Carsten Dominik @ 2010-05-12 12:41 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

Hi Dan,

On May 11, 2010, at 11:29 PM, Dan Davison wrote:

> Russell Adams <RLAdams@AdamsInfoServ.Com> writes:
>
>> On Sat, May 08, 2010 at 12:51:41PM +0200, Carsten Dominik wrote:
>>> We have now native inline image display in Org-mode, you can  
>>> toggle it
>>> with
>>>
>>> C-c C-x C-v
>>>
>>> This implementation uses overlays instead of text properties and
>>> therefore does not interfere with font-lock.
>>>
>>> - Carsten
>>
>> I'm using Org-Babel and R, and when I use C-c C-c to update the  
>> output
>> from a block of code, the image in emacs doesn't change.
>>
>> Ideas? v6.36
>
> Hi Russell,
>
> I struggled with this when images were text properties, i.e. before
> Carsten's implementation using overlays (thanks for C-c C-x C-v
> Carsten!)
>
> I think the answer may be clear-image-cache.

Yes, when you change an image on the disk, you need to clear the cache
to make sure it is not being pulled out of the cache.  image-refresh  
will
just clear the cache for an individual image, and make it redisplay in  
his way.

I have applied you patch, but I am clearing the cache before  
displaying the new images.  When removing the org images, it is  
possible that the image cache still contains other images.

I have also added new arguments to org-display-inline-images which  
will allow you
to call it in a way hat it refreshes existing images without clearing  
the entire cache.  Maybe you can do that in order to update after  
babel operations?


> I just tried that and C-c
> C-x C-v showed the new image afterwards. I'm not sure whether the
> following is acceptable in terms of emacs ecology, but it seems to do
> the trick:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/lisp/org.el b/lisp/org.el
> index c52aeb0..85f1219 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -15507,6 +15507,7 @@ with a description part will be inlined."
>  "Remove inline display of images."
>  (interactive)
>  (mapc 'delete-overlay org-inline-image-overlays)
> +  (clear-image-cache)
>  (setq org-inline-image-overlays nil))
> --8<---------------cut here---------------end--------------->8---
>
> Note also that we can make image display happen automatically after
> executing a babel block:
>
> (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
>
> In fact that was what I had in mind when adding that hook; it was just
> waiting for Carsten's function. So in my mind this gets us some of the
> way towards org-babel as an "interactive notebook", as discussed in
> another recent thread.

>
> Dan
>
> p.s. For what its worth, here is the code I was using to make images
> appear using text properties and Org font lock. I was intending to  
> post
> this when I was happy with the image refresh stuff, but it is probably
> redundant in light of the new functions using overlays. A certain  
> amount
> of messing about with image redisplay and cache functions is evident.

I did not know you were working on this, sorry for stepping on your  
toes here.
Let me know if you think we should go back to text properties and font- 
lock.

- Carsten


>
> --8<---------------cut here---------------start------------->8---
> (defun dan/org-fontify-image-links (limit)
> "Display links to images as images.
> If the description part of the link is empty display the image,
> otherwise do nothing. This function is intended to be called
> during font-lock fontification."
> (let ((case-fold-search t) file image)
>   (and dan/org-display-inline-images
>        (re-search-forward
>         (concat "\\[\\[file:\\(" iimage-mode-image-filename-regex "\ 
> \)\\]\\]") limit t)
>        (setq file (match-string 1))
>        (setq file (iimage-locate-file file (list default-directory)))
>        (setq image (create-image file))
>        (add-text-properties (match-beginning 0) (match-end 0) (list  
> 'display image))
>        ;; (clear-image-cache)
>        (image-refresh image)
>        ;; (redisplay)
>        ;; (redraw-frame)
>        ;; (redraw-display)
>        ;; (image-refresh image)
>        )))
>
> (setq dan/org-display-inline-images t)
> (add-hook 'org-font-lock-hook 'dan/org-fontify-image-links)
> --8<---------------cut here---------------end--------------->8---
>
>
>
>>
>> Thanks.
>>
>> ------------------------------------------------------------------
>> Russell Adams                            RLAdams@AdamsInfoServ.com
>>
>> PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/
>>
>> Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3
>>
>> _______________________________________________
>> 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
>
> _______________________________________________
> 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ messages in thread

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

Thread overview: 14+ 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
  -- strict thread matches above, loose matches on Subject: below --
2010-05-07  2:01 Nathan Neff
2010-05-07  2:16 ` Chris Thompson
2010-05-07  7:55   ` Carsten Dominik
2010-05-07 12:58     ` Dan Davison
2010-05-08 10:51       ` Carsten Dominik
2010-05-09 15:05         ` Daniel Martins
2010-05-09 17:23           ` Sebastian Rose
2010-05-11 19:14         ` Russell Adams
2010-05-11 21:29           ` Dan Davison
2010-05-12 12:41             ` Carsten Dominik

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