Subject: bug#75530: [PATCH v2 3/3] Remap read-only-mode for Grep Edit (bug#75530)

From: Liam Hupfer <[email-masked]>
Date: Sun, 2 Feb 2025 18:12:47 -0600

Like Dired and Occur, Grep buffers now remap read-only-mode to a useful
editing mode.

* lisp/progmodes/grep.el (grep-mode-map): Remap read-only-mode to
grep-change-to-grep-edit-mode.
(grep-edit-mode-map): Remap read-only-mode to grep-edit-save-changes.
* etc/NEWS (Grep): Document remaps.
---
 etc/NEWS               | 9 +++++----
 lisp/progmodes/grep.el | 6 ++++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index f25e8b2fe87..2e3c60799de 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -902,10 +902,11 @@ regardless of 'read-only-mode' bindings.
 
 +++
 *** Grep results can be edited to reflect changes in the originating file.
-Like Occur Edit mode, typing 'e' in the "*grep*" buffer will now make
-the 'grep' results editable.  The edits will be reflected in the buffer
-visiting the originating file.  Typing 'C-c C-c' will leave the Grep
-Edit mode.
+Like Occur Edit mode, typing 'e' or 'C-x C-q' (or your own
+'read-only-mode' binding) in the "*grep*" buffer will now make the
+'grep' results editable.  The edits will be reflected in the buffer
+visiting the originating file.  Typing 'C-c C-c' or 'C-x C-q' (or your
+own 'read-only-mode' binding) will leave the Grep Edit mode.
 
 ** TeX modes
 
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index d04e9945b0d..b29f56c9ed4 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -312,7 +312,8 @@ This keymap inherits from `compilation-minor-mode-map'."
   "TAB"       #'compilation-next-error
   "<backtab>" #'compilation-previous-error
 
-  "e"         #'grep-change-to-grep-edit-mode)
+  "e"         #'grep-change-to-grep-edit-mode
+  "<remap> <read-only-mode>" #'grep-change-to-grep-edit-mode)
 
 (easy-menu-define grep-menu-map grep-mode-map
   "Menu for grep buffers."
@@ -1083,7 +1084,8 @@ list is empty)."
 (defvar-keymap grep-edit-mode-map
   :doc "Keymap for `grep-edit-mode'."
   :parent text-mode-map
-  "C-c C-c" #'grep-edit-save-changes)
+  "C-c C-c" #'grep-edit-save-changes
+  "<remap> <read-only-mode>" #'grep-edit-save-changes)
 
 (defvar grep-edit-mode-hook nil
   "Hooks run when changing to Grep-Edit mode.")
-- 
2.47.1