Variable: read-only-mode-hook
read-only-mode-hook is a customizable variable defined in
simple.el.gz.
Value
nil
Documentation
Hook run after entering or leaving read-only-mode.
No problems result if this variable is not bound.
add-hook automatically binds it. (This is true for all hook variables.)
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(define-minor-mode read-only-mode
"Change whether the current buffer is read-only.
If buffer is read-only and `view-read-only' is non-nil, enter
view mode.
Do not call this from a Lisp program unless you really intend to
do the same thing as the \\[read-only-mode] command, including
possibly enabling or disabling View mode. Also, note that this
command works by setting the variable `buffer-read-only', which
does not affect read-only regions caused by text properties. To
ignore read-only status in a Lisp program (whether due to text
properties or buffer state), bind `inhibit-read-only' temporarily
to a non-nil value."
:variable buffer-read-only
(cond
((and (not buffer-read-only) view-mode)
(View-exit-and-edit)
(setq-local view-read-only t)) ; Must leave view mode.
((and buffer-read-only view-read-only
;; If view-mode is already active, `view-mode-enter' is a nop.
(not view-mode)
(not (eq (get major-mode 'mode-class) 'special)))
(view-mode-enter))))