nobiot / org-transclusion

Emacs package to enable transclusion with Org Mode
https://nobiot.github.io/org-transclusion/
GNU General Public License v3.0
902 stars 43 forks source link

refactor: Use built-in with-silent-modifications #207

Closed josephmturner closed 6 months ago

josephmturner commented 7 months ago

The org-transclusion-with-inhibit-read-only' macro can be replaced withwith-silent-modifications', which also brings a performance benefit by also setting buffer-undo-list' and inhibit-modification-hooks' to nil.

Potentially relevant to #106.

yantar92 commented 7 months ago

Joseph Turner @.***> writes:

The org-transclusion-with-inhibit-read-only' macro can be replaced withwith-silent-modifications', which also brings a performance benefit by also setting buffer-undo-list' and inhibit-modification-hooks' to nil.

Please, don't. Org mode's caching relies upon modification hooks to function.

-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92

josephmturner commented 6 months ago

Thank you for the review @yantar92 !!!

yantar92 commented 6 months ago

Joseph Turner @.***> writes:

Thank you for the review @yantar92 !!!

If you want to address #106, the problem is not with modification hooks, but with loading org-mode in temporary buffers - loading takes time. The common technique you can use to avoid this problem is having a temporary Org mode buffer that you do not close (thus keeping Org mode loaded) but erase, inserting new contents every time you need to.

For example, see https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org-element.el#n594

-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92

nobiot commented 6 months ago

If you want to address #106, the problem is not with modification hooks, but with loading org-mode in temporary buffers - loading takes time. The common technique you can use to avoid this problem is having a temporary Org mode buffer that you do not close (thus keeping Org mode loaded) but erase, inserting new contents every time you need to.

@yantar92 , thank you for this advice. I have tried caching with hash table because Org-transclusion parses the same Org buffer multiple times. This only had inconsistent results for performance gain at the time I tried. I think I can revisit the performance issue with the method you mention.

nobiot commented 6 months ago

@josephmturner , thank you for the PR and trying to improve Org-transclusion. I will try to add why it is the way it is in the source comment next time I update...

josephmturner commented 6 months ago

@nobiot Thank you! Please see #210 for the added explanation.