emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Dan Davison <davison@stats.ox.ac.uk>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: Wow -- adding images to an org file
Date: Wed, 12 May 2010 14:41:52 +0200	[thread overview]
Message-ID: <52CCB3C8-4AE4-4E51-A203-1C158F3B989F@gmail.com> (raw)
In-Reply-To: <87eihif7po.fsf@stats.ox.ac.uk>

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

  reply	other threads:[~2010-05-12 13:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-07  2:01 Wow -- adding images to an org file 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 [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-05-11 23:20 robut
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

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52CCB3C8-4AE4-4E51-A203-1C158F3B989F@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=davison@stats.ox.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    /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 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).