Subject: Re: bug#22472: 25.0.50; org-mode: latex fragments can't be un-rendered after a revert

From: Dima Kogan <[email-masked]>
Date: Wed, 03 Feb 2016 16:17:25 -0800

Hi. Thank you for replying. I just tried with the latest daily snapshot
from org-mode.org, and this bug is still valid, although the problem at
least becomes recoverable without killing and re-opening the org buffer.

Bastien Guerry <[email-masked]> writes:

> Dima Kogan <[email-masked]> writes:
>
>> 3. C-c C-x C-l
>>
>>    This renders the latex fragment to show the equation graphically. It
>>    also tells the user (in the mini-buffer) that C-c C-c will remove the
>>    rendering, and go back to text
>
> Latest stable version from Org does not use C-c C-c to remove the
> rendering.

Indeed C-c C-c no longer does this. There're no instructions in the
mini-buffer about how to unrender anymore. C-c C-x C-l is supposed
unrender anything that's rendered, and this works.

>> 4. M-x revert-buffer
>>
>>    At this point I would expect the render to revert to text, but it
>>    doesn't. This isn't necessarily a bug. However...
>
> (Why would reverting the buffer unrender the LaTeX fragment if the
> text file hasn't change?)

The latest org-mode still keeps the renders on a revert. This is a bug
because when a revert happens, emacs does not assume that the file
hasn't changed. In fact, it COULD have changed, so keeping the (possibly
out-of-date) render up is just wrong. Contrived example:

1. tst.org contains $\sqrt x$
2. C-c C-x C-l to render it
3. in the shell (outside of emacs): perl -p -i -e s/sqrt/sin/ tst.org
4. M-x revert-buffer
   Observe that the render stays up, even though the latex the render
   represents is no longer there

>> 5. C-c C-c
>>
>>    Here I ask emacs to un-render the fragment, but it does nothing. If
>>    #4 isn't a bug, then this is definitely a bug.

Right. But I can now use C-c C-x C-l again. Continuing instructions from
above

5. C-c C-x C-l
   One would expect this to unrender the equation, but org thinks that
   it is not rendered, so it attempts to render it. You get a new render
   of \sin x

6. C-c C-x C-l
   This is now an unrender to get back to the new text

So a revert puts emacs into an inconsistent state, where the equation is
rendered, but the source may or may not be there anymore, and where org
doesn't think there's a render there at all.