This patch adds a new variable 'revert-buffer-state-functions' that will allow any state to be saved and restored, not only the currently hard-coded 'read-only' state: