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.
Asked
Active
Viewed 58 times
4
-
Perhaps there's a read-only property for the overlay? – Dan Sep 06 '15 at 20:05
-
@Dan, I don't see it [here](https://www.gnu.org/software/emacs/manual/html_node/elisp/Overlay-Properties.html). – Mark Karpov Sep 06 '15 at 20:12
-
1I believe this: http://emacs.stackexchange.com/questions/13592/how-does-comint-mode-override-beginning-of-line-behavior-i-want-same-functional should help. – wvxvw Sep 06 '15 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 Karpov Sep 06 '15 at 20:46
1 Answers
2
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)))

Mark Karpov
- 4,893
- 1
- 24
- 53