I was working in Emacs and then suddenly, the slime-repl sbcl says text is read only. Well that's great because now I can't type anything into it. How do I fix this?
"Buffer is read-only" can be cured by C-x C-q
but as Drew & phils said,
"Text is read-only" is very different -- it means
some part of the buffer has a read-only property.
Try moving away from the read-only part, e.g., to the end of the buffer.
Emacs Lisp Manual > elisp.info > Text > Text Properties > Special Properties
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::.
thus to erase the entire buffer regardless:
M-: (let ((inhibit-read-only t)) (erase-buffer)) RET
or to remove all properties:
(let ((inhibit-read-only t)) (set-text-properties (point-min) (point-max) ()))
I can't offer any insight into why you ended up with undesirable read-only text properties, but I occasionally encounter similar situations and so find the following command useful.
Select the region in question (or C-xh for the entire buffer), and run M-x set-region-writeable
to remove the read-only text properties.
(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)))
M-x set-region-writable
. –
Schrecklichkeit Possible cause of such a message may be this: you are trying to print something over the REPL prompt, for example CL-US|ER> (+ 1 2)
. This text in the SLIME buffer is read-only. Note the space after >
, it is the part of the prompt.
Try typing C-c M-o RET
(it will clear the console and add a new line), I had a problem similar to yours and for it fixed it.
Q: How did I accidentally get a read-write buffer with a few lines that were read-only? A: Via (insert-buffer "*Occur*")
Q: How did I conquer the problem using a low-tech, but easy to remember solution? A: C-x C-v
, which runs the command find-alternate-file
. That's right, I simply wrote the file, then reopened it again, fresh from disk. All such weird properties get cleansed in the process.
I solved this by first opening two frames, one with a .lisp file opened and the other with the slime-repl.
From the frame with the .lisp file, I applied C-c C-j on a line of code (e.g (+ 1 2)).
This copied the line of code down to the slime-repl and evaluated it.
This also somehow solved the problem with the "text is read only" problem.
You can change read-only mode by doing: M-x
-> toggle-read-only
-> RET
(in other words press enter)
© 2022 - 2025 — McMap. All rights reserved.
C-x C-q
is how to enable or disable read-only mode. I'm not yet comfortable posting it as an answer, however, because you may be more interested in knowing what may have caused that behavior and I'm unfamiliar with the library you mentioned. – Garibaldiread-only
text property in effect? – PangaC-x C-q
command toggles "buffer is read only" while nothing seems to change "text is read only," which I got into because my finger hit the wrong key (I don't know which key I hit). Now I have to restart SLIME and lose my work. :( – Mageetext-read-only
) then the text at point has a read-only text property on it. The Elisp manual, nodeSpecial Properties
, says this: " Since changing properties counts as modifying the buffer, it is not possible to remove aread-only
property unless you know the special trick: bindinhibit-read-only
to a non-nil
value and then remove the property. *Note Read Only Buffers." – Nonpayment