dev*_*von 14
"缓冲区是只读的"可以通过,C-x C-q但正如Drew&phils所说,
"Text是只读的"是非常不同的 - 它意味着缓冲区的某些部分具有只读属性.
尝试远离只读部分,例如,移动到缓冲区的末尾.
Emacs Lisp手册> elisp.info>文本>文本属性>特殊属性
Since changing properties counts as modifying the buffer, it is not
possible to remove a `read-only' property unless you know the
special trick: bind `inhibit-read-only' to a non-`nil' value and
then remove the property. *Note Read Only Buffers::.
Run Code Online (Sandbox Code Playgroud)
因此,无论如何擦除整个缓冲区:
M-: (let ((inhibit-read-only t)) (erase-buffer)) RET
Run Code Online (Sandbox Code Playgroud)
或删除所有属性:
(let ((inhibit-read-only t)) (set-text-properties (point-min) (point-max) ()))
Run Code Online (Sandbox Code Playgroud)
我无法提供任何见解来解释为什么您最终会得到不需要的只读文本属性,但我偶尔会遇到类似的情况,因此发现以下命令很有用。
选择有问题的区域(或C-xh整个缓冲区),然后运行M-x set-region-writeable以删除只读文本属性。
(defun set-region-writeable (begin end)
"Removes the read-only text property from the marked region."
;; See http://stackoverflow.com/questions/7410125
(interactive "r")
(let ((modified (buffer-modified-p))
(inhibit-read-only t))
(remove-text-properties begin end '(read-only t))
(set-buffer-modified-p modified)))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4504 次 |
| 最近记录: |