I want to create overlay labels in text that appear at the start of a line, like so:
When selecting from the start of a newline, this looks good. But when I select the overlay's start to be from the middle of the line, I expectedly get the before-string
text appearing in the middle of the line as well:
To circumvent this, I prefix the before-string
with a newline character. Now, when I try to create an overlay from the middle of a line, I get:
However, now when I try to create an overlay from the start of the line, I get a superfluous visual newline:
I want to avoid this behavior by having the most pleasing visual appearance for this overlay.
I've tried to use overlay modification hooks, but that didn't end well because it is possible to delete from the start of the overlay to remove the preceding newline character, and the hook won't fire.
I must have the label outside of text (i.e. it must not be part of the "buffer"), and appear at the very beginning of the line. As far as I can tell right now, the only way to do this would be via buffer modification hooks, but I want to avoid that because I suspect it's going to be very slow when there's a high amount of overlays.