(defun org-update-dblock--make-read-only (orig-fn &rest args) (if buffer-file-name (let (s (inhibit-read-only t)) (save-excursion (org-beginning-of-dblock) (save-excursion (forward-line 1) (setq s (point))) (re-search-forward org-dblock-end-re nil t) (put-text-property s (point) 'read-only nil)) (unwind-protect (apply orig-fn args) (goto-char s) (re-search-forward org-dblock-end-re nil t) (beginning-of-line) (put-text-property s (point) 'read-only t))) (apply orig-fn args))) (advice-add 'org-update-dblock :around 'org-update-dblock--make-read-only) (defun org-dblock-make-read-only-find-file-hook () (when (derived-mode-p 'org-mode) (let ((inhibit-read-only t)) (org-map-dblocks (lambda () (let (s) (forward-char 1) (setq s (point)) (re-search-forward org-dblock-end-re nil t) (beginning-of-line) (put-text-property s (point) 'read-only t) (set-buffer-modified-p nil))))))) (add-hook 'find-file-hook 'org-dblock-make-read-only-find-file-hook) (provide 'mylisp-org-dblock-read-only-fix)