From fd74c6f4b81ffb6b373993ef2a5d80f888842397 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 24 Aug 2022 13:33:02 +0200 Subject: When reverting, preserve the readedness state set by `C-x C-q' * lisp/files.el (revert-buffer): Save the user's intention in a variable (bug#50431). * lisp/simple.el (read-only-mode): Use it. --- lisp/files.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lisp/files.el') diff --git a/lisp/files.el b/lisp/files.el index cf2a5221930..8596d9a8390 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6627,9 +6627,14 @@ preserve markers and overlays, at the price of being slower." ;; 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'. -- cgit v1.2.3