;; interface, but leaving the programmatic interface the same.
(interactive (list (not current-prefix-arg)))
(let ((revert-buffer-in-progress-p t)
- (revert-buffer-preserve-modes preserve-modes))
+ (revert-buffer-preserve-modes preserve-modes)
+ (state (and (boundp 'read-only-mode--state)
+ (list read-only-mode--state))))
(funcall (or revert-buffer-function #'revert-buffer--default)
- ignore-auto noconfirm)))
+ ignore-auto noconfirm)
+ (when state
+ (setq buffer-read-only (car state))
+ (setq-local read-only-mode--state (car state)))))
(defun revert-buffer--default (ignore-auto noconfirm)
"Default function for `revert-buffer'.
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."
+to a non-nil value.
+
+Reverting a buffer will keep the readedness state set by using
+this command."
:variable buffer-read-only
+ ;; We're saving this value here so that we can restore the
+ ;; readedness state after reverting the buffer to the value that's
+ ;; been explicitly set by the user.
+ (setq-local read-only-mode--state buffer-read-only)
(cond
((and (not buffer-read-only) view-mode)
(View-exit-and-edit)