I would like to imitate the way how most consoles work in a buffer, is there any way to do that? I.e. only allow appending text to the buffer, but not deleting?
Probably I could disable or advise some built-in functions which delete characters, but I'm afraid this isn't a very scalable solution... I could miss some.
As mentioned, you can set the read-only text-property. Or more simply you can set the
buffer-read-onlyvariable and then write a few commands that override it. For example (guaranteed 100% untested code ahead):As demonstrated by this example, the read-only-ness of text can be overriden by a command, so even the
read-onlytext-property won't guarantee 100% that the text will never be modified, but fairly few commands override the read-only information, so it should not be a serious problem in practice.Another approach would be to use
before-change-functionsand signal an error from there if the modification takes place before EOB. Might be a better approach: