If a buffer is read-only, then you cannot change its contents, although you may change your view of the contents by scrolling and narrowing.
Read-only buffers are used in two kinds of situations:
Here, the purpose is to inform the user that editing the buffer with the aim of saving it in the file may be futile or undesirable. The user who wants to change the buffer text despite this can do so after clearing the read-only flag with C-x C-q.
The special commands of these modes bind
let) or bind
t around the places where they themselves change the text.
This buffer-local variable specifies whether the buffer is read-only. The buffer is read-only if this variable is non-
If this variable is non-
nil, then read-only buffers and, depending on the actual value, some or all read-only characters may be modified. Read-only characters in a buffer are those that have non-
read-onlyproperties (either text properties or overlay properties). See Special Properties, for more information about text properties. See Overlays, for more information about overlays and their properties.
read-onlycharacter properties have no effect. If
inhibit-read-onlyis a list, then
read-onlycharacter properties have no effect if they are members of the list (comparison is done with
This command toggles whether the current buffer is read-only. It is intended for interactive use; do not use it in programs. At any given point in a program, you should know whether you want the read-only flag on or off; so you can set
buffer-read-onlyexplicitly to the proper value,
If arg is non-
nil, it should be a raw prefix argument.
tif the numeric value of that prefix argument is positive and to
nilotherwise. See Prefix Command Arguments.
This function signals a
buffer-read-onlyerror if the current buffer is read-only. See Using Interactive, for another way to signal an error if the current buffer is read-only.