I wonder if it is possible to prevent specific parts of a buffer from being editable. For example, when I have outlined my document in an org-mode file, I would like to prevent any accidental changes to the headlines, and only being able to edit the contents:
* Headline 1: not editable
Content under Headline 1 is editable.
* Headline 2: not editable
Content under Headline is editable.
** Subheadline 1 under Headline 2: not editable
Content under Subheadline 1 is editable
Or if I have code block in an org-file, I would like to prevent changes to the code block commands:
#+begin_src emacs-lisp <- not editable
(defun fun (a b) <- editable
(+ a b) <- editable
#+end_src <- not editable
EDIT: I would prefer a solution where the non-editable parts can still move up or down the y-axis in the buffer to ensure that content in between non-editable parts can be expanded:
#+begin_src emacs-lisp <- not editable, but can move up or down
(defun fun (a b) <- editable
(+ a b) <- editable
) <- editable
#+end_src <- not editable, but can move up or down