Closed Yevgnen closed 3 years ago
Thanks for the PR! This seems like a great idea.
I noticed a few bugs, though. First, since the timer is created inside save-excursion
, the timer could trigger when the point is not in the excursion anymore, causing the wrong fragment to be toggled. Second, if the point quickly moves around, entering and leaving the same fragment twice, two timers get created. This causes the preview to be toggled twice, leaving the fragment unchanged.
The first problem can be fixed pretty easily by moving the save-excursion
call inside the timer, but the second problem might require a mapping from fragments to timers. I'm not sure what the "key" to the mapping could be, since the user can edit most things about the fragment before the timer triggers.
Closing because of inactivity (sorry). It might be possible to get this working well, but it would probably take lots of complexity to avoid all the edge cases I mentioned in my first comment. Making fragment generation fully async would be cool too, but that's probably outside the scope of org-fragtog
.
When cursor is moving very fast across equations in different lines/columns,
org-latex-preview
is triggered very frequently and instantly. This commit adds a custom variableorg-fragtog-preview-delay
to allow preview to be shown when Emacs is idle.