与Emacs specific region read only密切相关,您如何删除缓冲区中文本区域上的只读属性。
例如,如果您在emacs中使用python shell并意外打印出一个巨大的列表,并希望从缓冲区中删除输出。
我使用以下内容。它与tcaswell的答案类似,但是处理缓冲区修改问题。
(defun set-region-read-only (begin end)
"See http://stackoverflow.com/questions/7410125"
(interactive "r")
(with-silent-modifications
(put-text-property begin end 'read-only t)))
(defun set-region-writeable (begin end)
"See http://stackoverflow.com/questions/7410125"
(interactive "r")
(with-silent-modifications
(remove-text-properties begin end '(read-only t))))
跟随the documentation中只读的神秘注释,从您只需要的区域中删除只读:
(defun remove-region-read-only (begin end)
(interactive "r")
(let ((inhibit-read-only t))
(remove-text-properties begin end '(read-only t)))
)