From d77d0880871061820b1cdf61f1d74f2a7e5224aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Sun, 1 Dec 2024 22:22:24 +0200 Subject: [PATCH] Make view-read-only behave like view-file Make view-mode also behave like less when entered through the view-read-only option similarly as done in in '1997-06-14 "Make view mode more similar to `less'' (ab7782fc244). * lisp/files.el (after-find-file): When opening a file which is read only and `view-read-only' is true leave view-mode with `kill-buffer-if-not-modified'. * lisp/view.el (view-mode): Document new behavior. --- lisp/files.el | 2 +- lisp/view.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index a65bc4a4ea2..2f062b45daf 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2874,7 +2874,7 @@ after-find-file (when (and buffer-read-only view-read-only (not (eq (get major-mode 'mode-class) 'special))) - (view-mode-enter)) + (view-mode-enter nil 'kill-buffer-if-not-modified)) (run-hooks 'find-file-hook))) (define-obsolete-function-alias 'report-errors 'with-demoted-errors "25.1") diff --git a/lisp/view.el b/lisp/view.el index 2ac7479739f..422d8a1f537 100644 --- a/lisp/view.el +++ b/lisp/view.el @@ -416,7 +416,7 @@ view-mode The effect of \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] depends on how view-mode was entered. If it was entered by view-file, view-file-other-window, view-file-other-frame, or \\[dired-view-file] \(\\[view-file], \\[view-file-other-window], -\\[view-file-other-frame], or the Dired mode v command), +\\[view-file-other-frame], `view-read-only', or the Dired mode v command), then \\[View-quit] will try to kill the current buffer. If view-mode was entered from another buffer, by \\[view-buffer], \\[view-buffer-other-window], \\[view-buffer-other frame], \\[view-file], -- 2.45.2