[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hook for buffers becoming writable/read-only

From: Steve Yegge
Subject: hook for buffers becoming writable/read-only
Date: Tue, 21 Jul 2009 20:39:42 -0700

I have a minor mode that wishes to disable itself when the buffer
becomes writable, but I do not see a way to do it.

The closest existing scenario I can see is view-mode, but view-mode
is special-cased in toggle-read-only, rather than listening on a hook.
This does not seem clean.

Moreover, most modes do not use toggle-read-only; they set the
buffer-read-only variable directly.  This has the (in my mind) unwanted
side-effect of leaving a writable buffer in view-mode if it is made
writable by setting the variable directly.

The semantics are admittedly a bit vague with respect to temporary
changes from let-binding buffer-read-only or inhibit-read-only, but
I would be satisfied if the hook were run on any persistent change
to the buffer-read-only variable.

Perhaps rather than creating a new hook, we could simply call the
before-change-functions and after-change-functions when the buffer
read-only status changes.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]