Subject: bug#75530: [PATCH v3 0/2] Tweak Wdired-related bindings

From: Liam Hupfer <[email-masked]>
Date: Thu, 6 Feb 2025 21:31:47 -0600

Some people prefer to keep the read-only-mode binding in Grep and Occur
buffers.  v3 instead rebinds ‘e’ in Dired to parallel Occur and Grep,
taking advantage of the fact that its previous binding is still
available on ‘RET’ and ‘f’.

Liam Hupfer (2):
  Remap read-only-mode in wdired-mode-map (bug#75530)
  Bind e in Dired to dired-toggle-read-only (bug#75530)

 doc/emacs/dired.texi |  4 +---
 etc/NEWS             | 10 ++++++++++
 lisp/dired.el        |  2 +-
 lisp/wdired.el       |  2 +-
 4 files changed, 13 insertions(+), 5 deletions(-)

base-commit: 1751739152149608d28853782ce53b0b9a749bb2
-- 
2.47.1

>From e8fa2fe0da65221861d70d2d12f1516885172757 Mon Sep 17 00:00:00 2001
From: Liam Hupfer <[email-masked]>
Date: Sun, 12 Jan 2025 12:24:38 -0600
Subject: [PATCH v3 1/2] Remap read-only-mode in wdired-mode-map (bug#75530)

dired-mode-map already remaps read-only-mode to dired-toggle-read-only.
Make wdired-mode-map remap as well, instead of hardcoding the default
C-x C-q.

* lisp/wdired.el (wdired-mode-map): Remap read-only-mode to wdired-exit.
* etc/NEWS (Dired): Document remap.
---
 etc/NEWS       | 6 ++++++
 lisp/wdired.el | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index ade635aa924..c7d1f24e74d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -900,6 +900,12 @@ Without 'dired-hide-details-hide-absolute-location':
 When 'dired-make-directory-clickable' is non-nil, clicking on the base
 name of the directory now reverts the Dired buffer.
 
+---
+*** 'wdired-exit' binding now respects user 'read-only-mode' bindings.
+If you add or change bindings for 'read-only-mode', 'wdired-exit' will
+respect those bindings.  Previously, it used a fixed 'C-x C-q' binding
+regardless of 'read-only-mode' bindings.
+
 ** Grep
 
 +++
diff --git a/lisp/wdired.el b/lisp/wdired.el
index c7409446b19..78d0c7e0716 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -160,7 +160,7 @@ nonexistent directory will fail."
   "C-c C-c" #'wdired-finish-edit
   "C-c C-k" #'wdired-abort-changes
   "C-c C-[" #'wdired-abort-changes
-  "C-x C-q" #'wdired-exit
+  "<remap> <read-only-mode>" #'wdired-exit
   "RET"     #'undefined
   "C-j"     #'undefined
   "C-o"     #'undefined
-- 
2.47.1

>From 3017b0496d8a68d18a93823d4935a1db25e4ea3a Mon Sep 17 00:00:00 2001
From: Liam Hupfer <[email-masked]>
Date: Wed, 5 Feb 2025 19:28:06 -0600
Subject: [PATCH v3 2/2] Bind e in Dired to dired-toggle-read-only (bug#75530)

This parallels the entry points to Occur Edit and Grep Edit. C-c C-c,
the exit point for those two edit modes, is already bound to exit
Wdired.

* lisp/dired.el (dired-mode-map): Bind e to dired-toggle-read-only.
* etc/NEWS: Document the change.
* doc/emacs/dired.texi: Update the manual accordingly.
---
 doc/emacs/dired.texi | 4 +---
 etc/NEWS             | 4 ++++
 lisp/dired.el        | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 07142e71713..779a27d8d4a 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -419,9 +419,7 @@ Visit the file described on the current line, like typing @kbd{C-x C-f}
 and supplying that file name (@code{dired-find-file}).  @xref{Visiting}.
 
 @item @key{RET}
-@itemx e
 @kindex RET @r{(Dired)}
-@kindex e @r{(Dired)}
 Equivalent to @kbd{f}.
 
 @ignore  @c This command seems too risky to document at all.
@@ -1633,7 +1631,7 @@ and erases all flags and marks.
 @findex wdired-change-to-wdired-mode
   Wdired is a special mode that allows you to perform file operations
 by editing the Dired buffer directly (the ``W'' in ``Wdired'' stands
-for ``writable'').  To enter Wdired mode, type @kbd{C-x C-q}
+for ``writable'').  To enter Wdired mode, type @kbd{C-x C-q} or @kbd{e}
 (@code{dired-toggle-read-only}) while in a Dired buffer.
 Alternatively, use the @samp{Immediate / Edit File Names} menu item.
 
diff --git a/etc/NEWS b/etc/NEWS
index c7d1f24e74d..4d13f19d626 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -906,6 +906,10 @@ If you add or change bindings for 'read-only-mode', 'wdired-exit' will
 respect those bindings.  Previously, it used a fixed 'C-x C-q' binding
 regardless of 'read-only-mode' bindings.
 
+---
+*** 'e' is now bound to 'dired-toggle-read-only'.
+'dired-find-file' remains available on 'f' and 'RET'.
+
 ** Grep
 
 +++
diff --git a/lisp/dired.el b/lisp/dired.el
index 91163186443..e4f9bcfcd24 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2394,7 +2394,7 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
   ;; Lower keys for commands not operating on all the marked files
   "a"       #'dired-find-alternate-file
   "d"       #'dired-flag-file-deletion
-  "e"       #'dired-find-file
+  "e"       #'dired-toggle-read-only
   "f"       #'dired-find-file
   "C-m"     #'dired-find-file
   "g"       #'revert-buffer
-- 
2.47.1