I'm not sure what you're asking, but I think you're asking how you might make certain parts of a buffer read-only.
You can do that by putting text-property read-only
on the text you want to be read-only. See the Elisp manual, node Special Properties. See also node Changing Properties.
The very simple way of inserting new read-only text is demonstrated in the next example. You can try this example in the *scratch*
buffer.
(insert (propertize "some text" 'read-only t))
After you inserted the read-only text it is important to know how to remove read-only text. You can ignore the read-only status of buffer text by setting the special variable inhibit-read-only
to a non-nil value.
Mark the read only text some text
in our example and type the following stuff:
M-: (let ((inhibit-read-only t)) (delete-region (region-beginning) (region-end)))
Note that the key sequence M-: runs the command eval-expression
and the expression is input in the mini-buffer.
It is also possible to set the read-only
text property for an already existing buffer-substring. That is demonstrated in the following example which produces the same read-only text as the former example.
(progn
(let ((pos1 (point)))
(insert "some text")
(put-text-property pos1 (point) 'read-only t)))