From 459025221b5d3a03a16717e6950168bd36b06795 Mon Sep 17 00:00:00 2001
From: Juri Linkov <juri@linkov.net>
Date: Wed, 19 Mar 2025 21:09:10 +0200
Subject: [PATCH] * lisp/files.el (save-some-buffers-action-alist): Fix
 'view-mode'.

Use 'view-mode-enter' instead of 'view-buffer' to ignore the 'special'
mode-class that prevents some modes from binding 'q' to 'exit-action'
that should call 'exit-recursive-edit' (bug#76745).

(cherry picked from commit 7016d1c8e3c16e8bfb61ce8ef96d85490a00c2eb)
---
 lisp/files.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index b5cd20287f4..771e55effad 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6355,7 +6355,10 @@ Before and after saving the buffer, this function runs
            "skip this buffer and mark it unmodified")
     (?\C-r
      ,(lambda (buf)
-        (view-buffer buf (lambda (_) (exit-recursive-edit)))
+        ;; Like 'view-buffer' but ignore 'special' mode-class
+        ;; because 'q' should call 'exit-action' in any case:
+        (switch-to-buffer buf)
+        (view-mode-enter nil (lambda (_) (exit-recursive-edit)))
         (recursive-edit)
         ;; Return nil to ask about BUF again.
         nil)
@@ -6371,7 +6374,8 @@ Before and after saving the buffer, this function runs
              (require 'diff)            ;for diff-no-select.
              (let ((diffbuf (diff-no-select (buffer-file-name buf) buf
                                             nil 'noasync)))
-               (view-buffer diffbuf (lambda (_) (exit-recursive-edit)))
+               (switch-to-buffer diffbuf)
+               (view-mode-enter nil (lambda (_) (exit-recursive-edit)))
                (recursive-edit)))
            ;; Return nil to ask about BUF again.
            nil)
-- 
2.39.5