awth13 / org-appear

Toggle visibility of hidden Org mode element parts upon entering and leaving an element
MIT License
375 stars 19 forks source link

org-appear conflicts with code invoking jit-lock functions #34

Open SPFabGerman opened 2 years ago

SPFabGerman commented 2 years ago

During testing, I noticed that when both org-appear and org-pretty-table are enabled, the unhiding of the markers doesn't work correctly. They are unhidden normally when the cursor enters them, but after a modification to the text, they are rehidden shortly after. This seems odd, since org-pretty-table doesn't modify anything about the post-command-hook and only registers a new jit-lock, which shouldn't be a problem at all, because org-appear uses with-silent-modifications and font-lock-ensure to basically "bypass" jit-mode. (When jit-mode is disabled, the problem doesn't occur. So it seems jit-mode is indeed the cause of the conflict.) Sadly I don't really know why this occurs or whose fault this error / problem / conflict is or what can be done to fix this. So any suggestions or fixes are greatly appreciated!

awth13 commented 2 years ago

Thank you for opening the issue!

I was able to reproduce it. I noticed that, with org-pretty-table enabled, the jit-lock-fontify-now runs twice within the Org element under cursor. So, what I suspect is happening is that we "fool" the jit-lock-mode on the first run with font-lock-ensure and then it runs again, with our ensure not mattering anymore.

At the moment, I am not sure why registering org-pretty-table-propertize-region with jit-lock makes the latter run twice and how to avoid it.

awth13 commented 2 years ago

This issue is now also blocking the transition to the new org-fold folding mechanism discussed in #5. org-fold-core uses jit-lock-refontify in the folding/unfolding function, which conflicts with the font-lock-ensure hack used by org-appear.

daeluk commented 1 year ago

Have there been any updates regarding this or are there any workarounds?

I've noticed that the same thing as in #4 happens to me when jit-lock-mode is enabled. org-appear works as expected with font-lock-mode disabled or jit-lock-debug-mode enabled.