How can I configure overlay text to be read-only? I know there is a text property read-only
, but that's not exactly what I want to use.
1 Answer
There is no predefined overlay property read-only
.
You can probably get the behavior you want by using property keymap
or local-keymap
.
You can use a keymap value that binds all normally self-inserting keys to do nothing or raise an error.
If you do that only for what you know at overlay-creation time to be self-inserting keys then that might not be sufficient. You can instead bind all keys in that keymap to a command that does nothing (e.g. ignore
) or that raises an error.
Someone else might have a better answer. But that's what I'd try first: use property keymap
or local-keymap
.
I also wonder what your actual use case is. Maybe this is an X-Y problem?
-
Thanks. Sounds like good idea. I will do that. My use case is that I want to hide some portion of buffer using overlay display property and I dont want that hidden part of buffer to be editable. It would be best to have completely immutable part of buffer, but killing <backspace> will be enough for me.– dev1223Commented Mar 15, 2020 at 13:16
-
Abort abort. I tried it and it failed. I assigned nil to <backspace> but characters were still vanishing. Maybe I will be forced to create mu custom backspace handler...– dev1223Commented Mar 15, 2020 at 13:29
-
nil
removes the binding in that particular keymap (whatever keymap you bind it tonil
in). If bound in another map that is active, it may still do something you don't want. Try binding it toignore
instead ofnil
.– DrewCommented Mar 15, 2020 at 15:50 -