When you hit SPC
or y
you're telling Emacs to change the text at the search hit. If its buffer is in read-only
mode then Emacs tells you it can't change the text because it's read-only.
Unfortunately, the doc for Q
(command dired-do-find-regexp-and-replace
) doesn't tell you anything at all about the dialog that it initiates, what keys you can press, and what they do. The author likely didn't bother, just assuming that you would (somehow?!!?) know that the command is based on the behavior of query-replace
. Or else that you would read the prompt that tells you you can hit ?
to find out what you can do.
Hitting ?
during the query-replacing shows you this:
- Type Space or
y
to replace one match, Delete or n
to skip to next,
RET
or q
to exit,
- Period to replace one match and exit,
- Comma to replace but not move point immediately,
C-r
to enter recursive edit (C-M-c
to get out again),
C-w
to delete match and recursive edit,
C-l
to clear the screen, redisplay, and offer same replacement again,
!
to replace all remaining matches in this buffer with no more questions,
^
to move point back to previous match,
u
to undo previous replacement,
U
to undo all replacements,
E
to edit the replacement string.
In multi-buffer replacements type Y
to replace all remaining
matches in all remaining buffers with no more questions,
N
to skip to the next buffer without replacing remaining matches
in the current buffer.
So one thing you can do, when you find out that the buffer where you want to make a change, is to use "C-r
to enter recursive edit", then use C-x C-q
to toggle read-only-mode
, then use "C-M-c
to get out again" (that is, end the recursive edit), then hit y
or SPC
to make one or more changes in that buffer.
FWIW, I just filed Emacs bug #55050, asking that the info you get by hitting ?
during query-replacement be added (directly or indirectly) to the doc for each command that makes use of that dialog.