In file I disable Read-only mode (by C-x C-q
):
But if I want to edit buffer I get message:
Text is read- only
In file I disable Read-only mode (by C-x C-q
):
But if I want to edit buffer I get message:
Text is read- only
The *Occur*
buffer will be in a major mode unsurprisingly called occur-mode
.
This mode, or perhaps the code that prepares it, or a combination of the two,
do a number of things, including these:
The best way to deal with the first two items is to get the buffer out of Occur mode and into some other mode: Perhaps text mode or fundamental mode will do: Just type M-x text-mode RET
or M-x fundamental-mode RET
(you don't have to type it all, thanks to tab completion). Or you can use M-x normal-mode
and let emacs pick the mode based on the ending of the file name (and possibly the contents, but probably not in this case).
You now have a reasonable keymap, and the buffer is not readonly.
To get rid of the text properties in the first line,
mark the first line, or the entire buffer if you wish
(C-x h
is handy for this),
then go to the Edit menu and select
Text Properties ▶ Remove Text Properties.
Note that the way to discover the existing properties is Edit ▶ Text Properties ▶ Describe Properties.
If you do that, after first placing the cursor in the first line of the *Occur*
buffer, you will see this:
There are text properties here:
face underline
occur-title #<buffer tt.txt>
read-only t
That last one, read-only t
, is your culprit.
*occur*
buffer is only a list of lines matching the pattern you searched for. Why do you want to edit that? If you do want to edit the text, perhaps in order to do something useful with it, just copy it into a new buffer. Then you can edit to your heart's content. … Oh wait, I missed some important information from the title of your question. It appears you have saved the occur buffer into a file, and wish to edit it? Then perhaps changing away fromoccur
mode by runningM-x normal-mode RET
will do the trick. – Harald Hanche-Olsen Jan 04 '19 at 17:23M-x occur
creates a plain text file. You should be able to edit that file normally when you re-open it, and it should not be inoccur-mode
when you do. Something else is going on here I think. – Tyler Jan 04 '19 at 18:17occur-mode
on. But your mode-line format looks strange for me. So I am not sure about that. – Tobias Jan 04 '19 at 18:17read-only
turned on, as you can see if you place the cursor on the line and runM-x describe-text-properties RET
. You can remove them by selecting all the text, then going to the Edit menu and selectingText Properties
→Remove Text Properties
. That runsfacemenu-remove-all
, which you can also run withM-a facemenu-remove-all RET
. – Harald Hanche-Olsen Jan 04 '19 at 18:44M-: (let ((inhibit-read-only t)) (remove-text-properties (point-min) (point-max) '(read-only nil)))
. – Tobias Jan 04 '19 at 18:48C-x C-q
, which then turned out not to be sufficient. No wonder; in addition to the first line having the `read-only? text property, in Occur mode you are also hampered by the keymap. It's way easier to just copy the entier text to a new buffer and edit it. – Harald Hanche-Olsen Jan 04 '19 at 18:48M-x normal-mode
does not clear the text properties. Yourfacemenu-remove-all
is still needed. – Tobias Jan 04 '19 at 18:56facemenu-remove-all
as an answer. @Alexei: Please accept HaraldHance-Olsen's answer to mark this question as done. – Tobias Jan 06 '19 at 21:08