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

Previous Next

Package: org-mode;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Wed, 27 Jan 2016 11:02:02 UTC

Severity: normal

Found in version 25.0.50

Done: Dima Kogan <dima <at> secretsauce.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22472 in the body.
You can then email your comments to 22472 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#22472; Package emacs. (Wed, 27 Jan 2016 11:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dima Kogan <dima <at> secretsauce.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 27 Jan 2016 11:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; org-mode: latex fragments can't be un-rendered after a revert
Date: Wed, 27 Jan 2016 03:01:26 -0800
Hi. I'm using a recent emacs from git, and a mostly-recent org-mode from
debian (Debian version 8.3.2-1). There's a bug:

1. emacs -Q

2. open an org-mode buffer that contains a latex fragment, for instance
==========
123

$\sqrt x$

123
=========

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

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

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.

Thanks!




Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Wed, 03 Feb 2016 06:46:02 GMT) Full text and rfc822 format available.

Message #8 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: Bastien Guerry <bzg <at> gnu.org>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: 22472 <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
Date: Wed, 03 Feb 2016 07:44:52 +0100
Hi Dima,

Dima Kogan <dima <at> secretsauce.net> 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.

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

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

AFAIK C-c C-c is not used to remove the rendering anymore.

Any chance you can test with the stable Org from GNU ELPA?

Thanks,

-- 
 Bastien




Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Thu, 04 Feb 2016 00:18:01 GMT) Full text and rfc822 format available.

Message #11 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Bastien Guerry <bzg <at> gnu.org>
Cc: 22472 <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
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 <bzg <at> gnu.org> writes:

> Dima Kogan <dima <at> secretsauce.net> 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.




Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Thu, 04 Feb 2016 01:55:01 GMT) Full text and rfc822 format available.

Message #14 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Bastien Guerry <bzg <at> gnu.org>
Cc: 22472 <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
Date: Wed, 03 Feb 2016 17:54:12 -0800
Dima Kogan <dima <at> secretsauce.net> writes:

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

This looks like an issue in emacs, rather than org. I think the right
solution is for a revert to delete all overlays. I.e.:

  (add-hook 'before-revert-hook 'delete-all-overlays)

This generally works, but is unideal because:


1. We'd want this to apply to org buffers, not to all emacs buffers

2. This works only if revert-buffer-function is nil or
revert-buffer--default.


If we don't want to delete overlays on revert, then
org-latex-fragment-image-overlays must be properly set to reflect the
overlay state, AND emacs should make sure the overlay is still valid on
revert.

Any particular thoughts?




Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Thu, 04 Feb 2016 08:34:02 GMT) Full text and rfc822 format available.

Message #17 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: Bastien Guerry <bzg <at> gnu.org>, 22472 <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
Date: Thu, 04 Feb 2016 09:35:13 +0100
[Message part 1 (text/plain, inline)]
Hello,

Dima Kogan <dima <at> secretsauce.net> writes:

> Dima Kogan <dima <at> secretsauce.net> writes:
>
>> 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.
>
> This looks like an issue in emacs, rather than org. I think the right
> solution is for a revert to delete all overlays. I.e.:
>
>   (add-hook 'before-revert-hook 'delete-all-overlays)
>
> This generally works, but is unideal because:
>
>
> 1. We'd want this to apply to org buffers, not to all emacs buffers
>
> 2. This works only if revert-buffer-function is nil or
> revert-buffer--default.
>
>
> If we don't want to delete overlays on revert, then
> org-latex-fragment-image-overlays must be properly set to reflect the
> overlay state, AND emacs should make sure the overlay is still valid on
> revert.
>
> Any particular thoughts?

Would the following patch (applied on maint) solve the problem?


Regards,

-- 
Nicolas Goaziou
[0001-Remove-LaTeX-overlay-when-text-below-is-modified.patch (text/x-patch, attachment)]

Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Thu, 04 Feb 2016 08:41:02 GMT) Full text and rfc822 format available.

Message #20 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Cc: Bastien Guerry <bzg <at> gnu.org>, 22472 <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
Date: Thu, 04 Feb 2016 00:40:17 -0800
Nicolas Goaziou <mail <at> nicolasgoaziou.fr> writes:

> Would the following patch (applied on maint) solve the problem?

Hi. I didn't observe anything acting differently with this patch. What
did you see it do? Was it supposed to unrender on revert, or to keep the
render, but update the state?




Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Thu, 04 Feb 2016 08:48:02 GMT) Full text and rfc822 format available.

Message #23 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: Bastien Guerry <bzg <at> gnu.org>, 22472 <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
Date: Thu, 04 Feb 2016 09:49:05 +0100
Dima Kogan <dima <at> secretsauce.net> writes:

> Nicolas Goaziou <mail <at> nicolasgoaziou.fr> writes:
>
>> Would the following patch (applied on maint) solve the problem?
>
> Hi. I didn't observe anything acting differently with this patch. What
> did you see it do? Was it supposed to unrender on revert, or to keep the
> render, but update the state?

As the commit message says, it is supposed to remove the overlay when
text below is modified (e.g. when using a replace-regexp). E.g.,

 1. Write \(1 + 2\)

 2. Toggle overlay with C-c C-x C-l

 3. M-% 2 RET 3 RET

 4. The overlay should have disappeared

I didn't test it with the `revert-buffer' command, but I would be
surprised that it doesn't run any modification hook.

Regards,

-- 
Nicolas




Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Thu, 04 Feb 2016 18:22:01 GMT) Full text and rfc822 format available.

Message #26 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Cc: Bastien Guerry <bzg <at> gnu.org>, 22472 <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
Date: Thu, 04 Feb 2016 10:21:34 -0800
Nicolas Goaziou <mail <at> nicolasgoaziou.fr> writes:

> Dima Kogan <dima <at> secretsauce.net> writes:
>
>> Nicolas Goaziou <mail <at> nicolasgoaziou.fr> writes:
>>
>>> Would the following patch (applied on maint) solve the problem?
>>
>> Hi. I didn't observe anything acting differently with this patch. What
>> did you see it do? Was it supposed to unrender on revert, or to keep the
>> render, but update the state?
>
> As the commit message says, it is supposed to remove the overlay when
> text below is modified (e.g. when using a replace-regexp). E.g.,
>
>  1. Write \(1 + 2\)
>
>  2. Toggle overlay with C-c C-x C-l
>
>  3. M-% 2 RET 3 RET
>
>  4. The overlay should have disappeared
>
> I didn't test it with the `revert-buffer' command, but I would be
> surprised that it doesn't run any modification hook.

Ah. Thanks for explaining. The patch helps somewhat, but one can still
get into an inconsistent state:

  1. Write \(1 + 2\)
  2. Toggle overlay with C-c C-x C-l
  3. M-x revert-buffer

After the revert, the overlay remains, which is arguably OK, since the
text has not changed. However after the revert org doesn't realize that
the overlay is still up: org-latex-fragment-image-overlays is nil.

I think the overlays should all disappear on a revert.

Thanks!




Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Fri, 05 Feb 2016 22:09:02 GMT) Full text and rfc822 format available.

Message #29 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: Bastien Guerry <bzg <at> gnu.org>, 22472 <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
Date: Fri, 05 Feb 2016 23:10:35 +0100
Hello,

Dima Kogan <dima <at> secretsauce.net> writes:

> Ah. Thanks for explaining. The patch helps somewhat, but one can still
> get into an inconsistent state:
>
>   1. Write \(1 + 2\)
>   2. Toggle overlay with C-c C-x C-l
>   3. M-x revert-buffer
>
> After the revert, the overlay remains, which is arguably OK, since the
> text has not changed. However after the revert org doesn't realize that
> the overlay is still up: org-latex-fragment-image-overlays is nil.

Indeed. 

`org-latex-fragment-image-overlays' is a local variable and
`revert-buffer' calls `normal-mode', which, in turn, calls
`fundamental-mode'. The latter calls `kill-all-local-variables'.
Information is lost.

I don't think that `org-latex-fragment-image-overlays' is useful,
anyway. So I removed it, along with that bug, hopefully.

> I think the overlays should all disappear on a revert.

I'm not convinced that an unmodified overlay should disappear.

Thank you for the report.


Regards,

-- 
Nicolas Goaziou




Information forwarded to emacs-orgmode <at> gnu.org:
bug#22472; Package org-mode. (Fri, 05 Feb 2016 22:32:02 GMT) Full text and rfc822 format available.

Message #32 received at 22472 <at> debbugs.gnu.org (full text, mbox):

From: "Stephen J. Barr" <stevejb <at> uw.edu>
To: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Cc: Bastien Guerry <bzg <at> gnu.org>, 22472 <at> debbugs.gnu.org,
 Dima Kogan <dima <at> secretsauce.net>
Subject: Re: [O] bug#22472: 25.0.50; org-mode: latex fragments can't be
 un-rendered after a revert
Date: Fri, 5 Feb 2016 14:28:31 -0800
[Message part 1 (text/plain, inline)]
I was in the progress of writing my own email about this same issue. I was
not aware that C-c C-c is no longer used for disabling overlays. If this is
the case, what is the correct workflow for toggling these previews on and
off?

Thanks,

-Stephen



Stephen J. Barr
PhD Candidate, Operations Management
Dept: Information Systems and Operations Management (ISOM)
Michael G. Foster School of Business
University of Washington
Phone:  425 516 5012
Email: stevejb <at> uw.edu
Twitter: @stevejb
Website: http://stephen.planetbarr.com



On Fri, Feb 5, 2016 at 2:10 PM, Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
wrote:

> Hello,
>
> Dima Kogan <dima <at> secretsauce.net> writes:
>
> > Ah. Thanks for explaining. The patch helps somewhat, but one can still
> > get into an inconsistent state:
> >
> >   1. Write \(1 + 2\)
> >   2. Toggle overlay with C-c C-x C-l
> >   3. M-x revert-buffer
> >
> > After the revert, the overlay remains, which is arguably OK, since the
> > text has not changed. However after the revert org doesn't realize that
> > the overlay is still up: org-latex-fragment-image-overlays is nil.
>
> Indeed.
>
> `org-latex-fragment-image-overlays' is a local variable and
> `revert-buffer' calls `normal-mode', which, in turn, calls
> `fundamental-mode'. The latter calls `kill-all-local-variables'.
> Information is lost.
>
> I don't think that `org-latex-fragment-image-overlays' is useful,
> anyway. So I removed it, along with that bug, hopefully.
>
> > I think the overlays should all disappear on a revert.
>
> I'm not convinced that an unmodified overlay should disappear.
>
> Thank you for the report.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>
>
>
>
[Message part 2 (text/html, inline)]

Reply sent to Dima Kogan <dima <at> secretsauce.net>:
You have taken responsibility. (Sat, 06 Feb 2016 08:55:02 GMT) Full text and rfc822 format available.

Notification sent to Dima Kogan <dima <at> secretsauce.net>:
bug acknowledged by developer. (Sat, 06 Feb 2016 08:55:02 GMT) Full text and rfc822 format available.

Message #37 received at 22472-done <at> debbugs.gnu.org (full text, mbox):

From: Dima Kogan <dima <at> secretsauce.net>
To: Nicolas Goaziou <mail <at> nicolasgoaziou.fr>
Cc: Bastien Guerry <bzg <at> gnu.org>, 22472-done <at> debbugs.gnu.org
Subject: Re: bug#22472: 25.0.50;
 org-mode: latex fragments can't be un-rendered after a revert
Date: Sat, 06 Feb 2016 00:54:24 -0800
Nicolas Goaziou <mail <at> nicolasgoaziou.fr> writes:

> Dima Kogan <dima <at> secretsauce.net> writes:
>
>> Ah. Thanks for explaining. The patch helps somewhat, but one can still
>> get into an inconsistent state:
>>
>>   1. Write \(1 + 2\)
>>   2. Toggle overlay with C-c C-x C-l
>>   3. M-x revert-buffer
>>
>> After the revert, the overlay remains, which is arguably OK, since the
>> text has not changed. However after the revert org doesn't realize that
>> the overlay is still up: org-latex-fragment-image-overlays is nil.
>
> Indeed. 
>
> `org-latex-fragment-image-overlays' is a local variable and
> `revert-buffer' calls `normal-mode', which, in turn, calls
> `fundamental-mode'. The latter calls `kill-all-local-variables'.
> Information is lost.
>
> I don't think that `org-latex-fragment-image-overlays' is useful,
> anyway. So I removed it, along with that bug, hopefully.

Yes, things look consistent after your patch.


>> I think the overlays should all disappear on a revert.
>
> I'm not convinced that an unmodified overlay should disappear.

Sure. If we can keep everything consistent, then keeping the overlays is
probably better.

Thank you very much! I'm closing this bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 05 Mar 2016 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 107 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.