nobiot / org-transclusion

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

Translusion fringe not appearing #201

Closed ahmed-shariff closed 1 year ago

ahmed-shariff commented 1 year ago

This is a continuation of the discussion from #126

The issue I was having was the fringe was not appearing on the transluded region. But it had the background color I set to org-transclusion and also the fringe in the source buffer.

The org-transclusion-content-insert function seems to be setting the line-prefix and warp-prefix for the corresponding region as text-properties for the transclusion region. But uses the overlays to modify that for the source region. After transcluding, when checking the text-properties of the tranclusion region, line-prefix and warp-prefix are nil. I don't fully understand how font lock and text properties work, but I am assuming this is why the source buffer has the fringe and the tranclusion buffer doesn't. With the cursor on the tranclusion region, if I do the following:

(overlay-put (text-clone-make-overlay (marker-position (get-text-property (point) 'org-transclusion-beg-mkr)) (marker-position (get-text-property (point) 'org-transclusion-end-mkr)) (current-buffer)) 'wrap-prefix (org-transclusion-propertize-transclusion))

(which is using overlay to set the line-prefix and warp-prefix by extracting other values in the text properties) I get the fringe in the buffer.

As a workaround, I am doing the following:

  (defun org-transclusion-content-insert-add-overlay (beg end)
    "Add fringe after transclusion."
    (overlay-put (text-clone-make-overlay beg end (current-buffer))
                 'line-prefix
                 (org-transclusion-propertize-transclusion))
    (overlay-put (text-clone-make-overlay beg end (current-buffer))
                 'wrap-prefix
                 (org-transclusion-propertize-transclusion)))

  (add-hook 'org-transclusion-after-add-functions #'org-transclusion-content-insert-add-overlay)

As mentioned in #126 it might not be trivial to use overlay instead of text-properties.

ahmed-shariff commented 1 year ago

Welp, I did a bit more digging - trying to figure out what is setting the line-prefix and warp-prefix to nil. Turns out org-modern was the culprit. It seems to be setting the line-prefix and warp-prefix to nil if org-indent is not enabled 😅

nobiot commented 1 year ago

Now that minad has closes the issue, I guess we can close this one too?

ahmed-shariff commented 1 year ago

Hey, yeah, sorry, forgot about this one! Thank you for the help.