commit f73744c92c84e8037b288cf829ebfc05df1256fa parent f0cdd26fb67b88c1832413e5312892b6533a386b Author: Alex Balgavy <alex@balgavy.eu> Date: Mon, 11 Apr 2022 16:50:57 +0200 emacs: functions to toggle region writable Diffstat:
M | emacs/config.org | | | 18 | ++++++++++++++++++ |
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/emacs/config.org b/emacs/config.org @@ -1418,6 +1418,24 @@ Let a period followed by a single space be treated as end of sentence: #+begin_src emacs-lisp (setq sentence-end-double-space nil) #+end_src +** Make region readonly or writable +#+begin_src emacs-lisp + (defun za/set-region-read-only (begin end) + "Sets the read-only text property on the marked region. + Use `set-region-writeable' to remove this property." + ;; See https://stackoverflow.com/questions/7410125 + (interactive "r") + (with-silent-modifications + (put-text-property begin end 'read-only t))) + + (defun za/set-region-writeable (begin end) + "Removes the read-only text property from the marked region. + Use `set-region-read-only' to set this property." + ;; See https://stackoverflow.com/questions/7410125 + (interactive "r") + (with-silent-modifications + (remove-text-properties begin end '(read-only t)))) +#+end_src * Markdown Markdown mode settings.