branch: externals/org-transclusion
commit 0a0b683feec44814faa272bb7eb418acb42787b8
Author: gggion <[email protected]>
Commit: gggion <[email protected]>
fix: remove source fringe indicators when transclusion is removed
Modify org-transclusion-remove to clean up fringe indicators from
source buffer when transclusion is removed, and run hook for
extensions to perform additional cleanup.
* org-transclusion.el (org-transclusion-remove): After deleting
transclusion overlay, retrieve source overlay from org-transclusion-pair
property, extract its buffer and region, call
org-transclusion-remove-fringe-from-region to clean up fringe
indicators, then run org-transclusion-after-remove-functions hook.
Without cleanup, fringe indicators accumulate in source buffer's
line-prefix and wrap-prefix properties. Each add/remove cycle appends
another fringe, creating "x", "xx", "xxx", etc. Cleaning up restores
the prefix to its pre-transclusion state.
---
org-transclusion.el | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/org-transclusion.el b/org-transclusion.el
index 8b44918bb2..ab24238621 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -560,6 +560,18 @@ When success, return the beginning point of the keyword
re-inserted."
beg
(when (org-transclusion-within-live-sync-p)
(org-transclusion-live-sync-exit))
+
+ ;; Clean up source buffer fringe indicators before deleting overlay
+ (when (overlay-buffer tc-pair-ov)
+ (let ((src-buf (overlay-buffer tc-pair-ov))
+ (src-beg (overlay-start tc-pair-ov))
+ (src-end (overlay-end tc-pair-ov)))
+ ;; Remove our fringe indicators from source
+ (org-transclusion-remove-fringe-from-region src-buf src-beg
src-end)
+ ;; Run hooks for extensions to do additional cleanup
+ (run-hook-with-args 'org-transclusion-after-remove-functions
+ src-buf src-beg src-end)))
+
(delete-overlay tc-pair-ov)
(org-transclusion-with-inhibit-read-only
(save-excursion