Is there any way to forbid insertion of text before and after specific overlay? (I mean on the same line that displays overlay.) Forbid means that either changes cancelled somehow or immediately reverted, or something like this. I'm ready to consider other options as well.
-
Perhaps there's a read-only property for the overlay?– Dan ♦Sep 6, 2015 at 20:05
-
@Dan, I don't see it here.– Mark KarpovSep 6, 2015 at 20:12
-
1I believe this: emacs.stackexchange.com/questions/13592/… should help.– wvxvwSep 6, 2015 at 20:40
-
@wvxvw, this is definitely useful link. I'll try to experiment and see if it does what I want. According to that answer I can set text properties of text from beginning of line till overlay and from end of overlay to end of line so that these regions are indeed "read-only".– Mark KarpovSep 6, 2015 at 20:46
1 Answer
Indeed @Dan's advice helped me. My final solution is:
Mark all text beginning one character before overlay (that is including newline before it) and ending where overlay ends as read-only:
(set-text-properties (1- beg) end '(read-only t))
Now create overlay.
When it's time to remove overlay don't forget to remove
read-only
property as well:(let ((inhibit-read-only t)) (remove-text-properties (1- beg) end '(read-only nil)))