Working on #25, I discovered another issue with the way prev-frag is enabled upon leaving. When an active (disabled) fragment is edited, its bounds change; org-fragtog, however, still uses the old bounds (stored in prev-frag) when the cursor leaves and the fragment is enabled. This is not an issue most of the time since org-latex-preview and org-clear-latex-preview are smart with how they treat toggled regions. Under certain conditions, however, this may cause another fragment to be incorrectly disabled. Here's an example:
$This LaTeX fragment$
$Next LaTeX fragment$
If we delete the word "LaTeX" in this fragment and move the cursor to the empty line that follows, the next LaTeX fragment will be disabled.
Testing
The next LaTeX fragment is no longer disabled in the situation described above.
Comments
I had and fixed the same issue in org-appear some time ago but didn't think it also affects org-fragtog. Turns out org-clear-latex-preview is not smart enough. I decided not to implement this fix within #25 because it's an unrelated issue.
Rationale
Working on #25, I discovered another issue with the way
prev-frag
is enabled upon leaving. When an active (disabled) fragment is edited, its bounds change;org-fragtog
, however, still uses the old bounds (stored inprev-frag
) when the cursor leaves and the fragment is enabled. This is not an issue most of the time sinceorg-latex-preview
andorg-clear-latex-preview
are smart with how they treat toggled regions. Under certain conditions, however, this may cause another fragment to be incorrectly disabled. Here's an example:If we delete the word "LaTeX" in this fragment and move the cursor to the empty line that follows, the next LaTeX fragment will be disabled.
Testing
The next LaTeX fragment is no longer disabled in the situation described above.
Comments
I had and fixed the same issue in
org-appear
some time ago but didn't think it also affectsorg-fragtog
. Turns outorg-clear-latex-preview
is not smart enough. I decided not to implement this fix within #25 because it's an unrelated issue.