help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making a region read-only


From: michael-franzese
Subject: Making a region read-only
Date: Thu, 24 Dec 2020 11:08:46 +0100

I aw writing a function to make a region read only.  I am using
"put-text-property", but I have seen the variable "inhibit-read-only".
What shall I do with it, shall I use it?

(defvar region-rwcycle-state 1)
(defun region-read-write-cycle (start end)
  "Cycles read-only status of a region in a buffer."
  (interactive "*r")

  (pcase region-rwcycle-state
    (1 (message "Disable: Region Read Only")
       (put-text-property start end 'read-only nil)
       (setq region-rwcycle-state 2))

    (2 (message "Enable: Region Read Only")
       (put-text-property start end 'read-only t)
       (setq region-rwcycle-state 1)) ))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]