refactor: consolidate fringe management functions#285
refactor: consolidate fringe management functions#285gggion wants to merge 1 commit intonobiot:mainfrom
Conversation
* org-transclusion.el (org-transclusion-add-fringes): Renamed from `org-transclusion-add-fringe-to-region'. Now uses overlay properties when `org-indent-mode' is inactive (which survive `revert-buffer'), and text properties when active (to preserve per-line indentation). (org-transclusion-remove-fringes): Renamed from `org-transclusion-remove-fringe-from-region'. Handles both overlay and text property removal based on `org-indent-mode' state. (org-transclusion--prefix-has-fringe-p): Renamed from `org-transclusion-prefix-has-fringe-p' with double-dash to indicate internal function. (org-transclusion--make-fringe-string): New helper function to create fringe indicator strings for both graphical and terminal displays. (org-transclusion-source-overlay-modified): Simplified to only reapply text properties when `org-indent-mode' is active but the indent-mode extension is not loaded. Guard reference to `org-transclusion-indent-mode' with `boundp' check to avoid void-variable errors when extension is not loaded. * org-transclusion-indent-mode.el: Update all function calls to use new names: `org-transclusion-add-fringes', `org-transclusion-remove-fringes', and `org-transclusion--prefix-has-fringe-p'. The original implementation before the indent-mode additions used overlay properties for fringes, which survived buffer reverts. The initial per-line text property approach was necessary for `org-indent-mode' compatibility but broke the non-indent case where fringes disappeared after `revert-buffer' in the source buffer. This hybrid approach uses overlay properties when `org-indent-mode' is inactive (preserving `revert-buffer' behavior) and text properties when active (preserving per-line indentation from org-indent). When `org-indent-mode' is active without the indent-mode extension loaded, fringes are reapplied during normal buffer modifications via the overlay modification hook, but NOT after `revert-buffer' (which doesn't trigger modification hooks when content is unchanged). Users who need full `org-indent-mode' support including buffer reverts should load the `org-transclusion-indent-mode' extension. Summary: - indent-mode DISABLED: uses overlays for fringe placement, survives through revert-buffer. - indent-mode ENABLED + transclusion-indent-mode DISABLED: uses text-properties for fringe placement, which dissapear after executing revert-buffer on the transclusion source (acceptable). - indent-mode ENABLED + transclusion-indent-mode ENABLED: fringes are reapplied after revert-buffer while the transclusion is active. Addresses nobiot#284
|
STATUS: currently debugging graphical and terminal emacs instances:
|
|
@nobiot one question: would it be better to make this PR directly to the feat/transient branch? |
|
@gggion ,
I have just merged the feat/transient branch with main branch. It is significantly diverged from the main branch before the merge. Could I ask you to look into rebasing before proceeding any further? |
Fringe management functions consolidated into:
With this I’ve also adapted all places where the previous fringe placemente functions where being called in org-transclusion.el and org-transclusion-indent-mode.el
such as
org-transclusion-indent-mode.el
Same deal on
org-transclusion.elBesides refactoring the fringe functions, I’ve also added an hybrid approach that applies fringes through different mechanisms depending on org-indent-mode being enabled or not.
This was due to the following problem: If indent-mode and the transclusion-indent-mode extension are disabled, the per-line text property approach is unable to preserve fringes in the source when executing
revert-buffer. The original implementation before the indent-mode additions did not have this issue because it placed the fringes as overlay properties, which survived buffer-revert and other changes to the buffer..So, since fringe placement through overlays is only an issue if we want to preserve indentation, I’ve made it so fringes will be placed through overlays WHEN org-indent-mode is disabled. If not, then we’ll default to the per line text property approach.
Another detail is that when
org-indent-modeis active without the transclusion-indent-mode extension loaded, fringes can still be reapplied during normal buffer modifications via the overlay modification hook, but NOT afterrevert-buffer(which doesn't trigger modification hooks when content is unchanged). Users who need fullorg-indent-modesupport including buffer reverts should load theorg-transclusion-indent-modeextension.SUMMARY: