1
votes

I have a fair amount of buffers open in Emacs and switch between them using C-x b. However, fairly often i find myself returning to an earlier accessed buffer that now has read-only rights. It can be toggled back by M-x toggle-read-only. I wonder why i (automatically?) get a read-only buffer when i return to it, and, how it can be avoided.

I have only a single instance of Emacs open, and do not change the files underlying the buffers in the meanwhile.

3
I've never seen that behaviour before - Flexo
Strange, I've never seen this before either. Do you run any particular package that might cause this (like global-auto-revert-mode?) You might have accidentally hit C-x C-q (which runs toggle-read-only), if so, you can unbind this to avoid this. - Lindydancer

3 Answers

4
votes

Returning to a buffer definitely does not make it read-only.

You can put an advice around toggle-read-only to see if there in an inadvertent call somewhere.

(defadvice toggle-read-only (around invoke-debugger activate)
  "invoke debugger to see the call stack"
  (debug ""))

If that doesn't help you can even put an advice on setq and enter debugger when buffer-read-only is getting assigned.

1
votes

I believe this happens quite often on AZERTY keyboards, where Q and S are adjacent, and one toggles the buffer to read-only mode instead of saving it.

0
votes

This is not a default emacs behavior. Supply some more data as emacs version/platform etc... Look at you init files (including .emacs) which has buffer-read-only for some reason. In any case, you can avoid by adding hook to switch-buffer ( or C-h k C-x b). Use toggle-read-only with negative argument.