2

On creation of an overlay it's possible to specify the "insertion type" / advance behavior of the beginning and end markers:

(make-overlay BEG END &optional BUFFER FRONT-ADVANCE REAR-ADVANCE)

It's possible to change the insertion behavior for markers directly:

(set-marker-insertion-type MARKER TYPE)

Set the insertion-type of MARKER to TYPE. If TYPE is t, it means the marker advances when you insert text at it. If TYPE is nil, it means the marker stays behind when you insert text at it.

From Managing Overlays:

"Do not try modifying the markers in the overlay by hand, as that fails to update other vital data structures and can cause some overlays to be lost."

I get that markers are not easily accessible for the purposes of encapsulation, but I really want to temporarily change the insertion behavior temporarily! :-) I suppose that I can destructively re-create the overlay twice, but that involves copying properties and any costs associated with underlying overlay data structures.

Q: How can I efficiently modify overlay marker insertion types?

If I were to circumvent the intended information-hiding and obtained a reference to individual markers, would modifying the insertion type temporarily (and inserting text) violate an essential invariant for overlay data structures?

2

It would be safe to let the user change the insertion type of the start/end position of an overlay. It just hasn't been needed until now. I guess those people who have needed such a thing haven't been vocal enough, or manually adjusting the overlay position (rather than its insertion type) was easy enough.

[ BTW: the fact that overlays use markers is an internal implementation detail. It will hopefully change in the future. ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.