aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2025-12-31 18:10:48 +0000
committerSean Whitton2025-12-31 18:10:48 +0000
commita03419b52c9b87ac2e9fea1d0ccf584ae77debe8 (patch)
tree3f830fd188b8add869da3d38ca482ea7e7983f32
parent466627ffebf05173b1aba18b185aaed85e39ab20 (diff)
downloademacs-a03419b52c9b87ac2e9fea1d0ccf584ae77debe8.tar.gz
emacs-a03419b52c9b87ac2e9fea1d0ccf584ae77debe8.zip
Factor out undo-ignore-read-only (bug#80049)
* lisp/vc/diff-mode.el (diff-undo): Rename to undo-ignore-read-only. (diff-mode-shared-map): Update "<remap> <undo>" binding. * lisp/simple.el (undo-ignore-read-only): Rename from diff-undo. * lisp/dired.el (dired-undo): * lisp/proced.el (proced-undo): Call it. New numeric prefix argument to specify a repeat count. * doc/emacs/dired.texi (Marks vs Flags): * etc/NEWS: Document the change.
-rw-r--r--doc/emacs/dired.texi3
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/dired.el8
-rw-r--r--lisp/proced.el8
-rw-r--r--lisp/simple.el7
-rw-r--r--lisp/vc/diff-mode.el8
6 files changed, 26 insertions, 16 deletions
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 599c0308cec..a70a0444d12 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -733,7 +733,8 @@ Auto-Revert mode, you might want to set
733Undo changes in the Dired buffer, such as adding or removing 733Undo changes in the Dired buffer, such as adding or removing
734marks (@code{dired-undo}). @emph{This command does not revert the 734marks (@code{dired-undo}). @emph{This command does not revert the
735actual file operations, nor recover lost files!} It just undoes 735actual file operations, nor recover lost files!} It just undoes
736changes in the buffer itself. 736changes in the buffer itself. Like with @code{undo}, a numeric prefix
737argument specifies a repeat count.
737 738
738In some cases, using this after commands that operate on files can 739In some cases, using this after commands that operate on files can
739cause trouble. For example, after renaming one or more files, 740cause trouble. For example, after renaming one or more files,
diff --git a/etc/NEWS b/etc/NEWS
index 8dd3bdbca2e..89710fa82ca 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -888,6 +888,14 @@ failed.
888You can now use 'C-u C-x .' to clear the fill prefix, similarly to how 888You can now use 'C-u C-x .' to clear the fill prefix, similarly to how
889you could already use 'C-u C-x C-n' to clear the goal column. 889you could already use 'C-u C-x C-n' to clear the goal column.
890 890
891+++
892** New prefix argument for 'C-/' in Dired and Proced modes.
893The Dired and Proced major modes bind mode-specific undo commands to the
894same keys to which 'undo' is globally bound, 'C-/', 'C-_' and 'C-x u'.
895These commands did not previously accept a prefix argument.
896Now a numeric prefix argument specifies a repeat count, just like it
897already did for 'undo'.
898
891 899
892* Changes in Specialized Modes and Packages in Emacs 31.1 900* Changes in Specialized Modes and Packages in Emacs 31.1
893 901
diff --git a/lisp/dired.el b/lisp/dired.el
index 2a8b23b69b6..450b408975e 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2893,13 +2893,13 @@ Keybindings:
2893 (concat "\\`d'-elete, \\`u'-ndelete, \\`x'-punge, \\`f'-ind, " 2893 (concat "\\`d'-elete, \\`u'-ndelete, \\`x'-punge, \\`f'-ind, "
2894 "\\`o'-ther window, \\`R'-ename, \\`C'-opy, \\`h'-elp")))) 2894 "\\`o'-ther window, \\`R'-ename, \\`C'-opy, \\`h'-elp"))))
2895 2895
2896(defun dired-undo () 2896(defun dired-undo (&optional arg)
2897 "Undo in a Dired buffer. 2897 "Undo in a Dired buffer.
2898A numeric ARG serves as a repeat count.
2898This doesn't recover lost files, it just undoes changes in the buffer itself. 2899This doesn't recover lost files, it just undoes changes in the buffer itself.
2899You can use it to recover marks, killed lines or subdirs." 2900You can use it to recover marks, killed lines or subdirs."
2900 (interactive nil dired-mode) 2901 (interactive "P" dired-mode)
2901 (let ((inhibit-read-only t)) 2902 (undo-ignore-read-only arg)
2902 (undo))
2903 (dired-build-subdir-alist) 2903 (dired-build-subdir-alist)
2904 (message "Change in Dired buffer undone. 2904 (message "Change in Dired buffer undone.
2905Actual changes in files cannot be undone by Emacs.")) 2905Actual changes in files cannot be undone by Emacs."))
diff --git a/lisp/proced.el b/lisp/proced.el
index ca2fa694665..90b4e1445ce 100644
--- a/lisp/proced.el
+++ b/lisp/proced.el
@@ -2311,13 +2311,13 @@ STRING is an overall summary of the failures."
2311 (describe-mode) 2311 (describe-mode)
2312 (message (substitute-command-keys proced-help-string)))) 2312 (message (substitute-command-keys proced-help-string))))
2313 2313
2314(defun proced-undo () 2314(defun proced-undo (&optional arg)
2315 "Undo in a Proced buffer. 2315 "Undo in a Proced buffer.
2316A numeric ARG serves as a repeat count.
2316This doesn't recover killed processes, it just undoes changes in the Proced 2317This doesn't recover killed processes, it just undoes changes in the Proced
2317buffer. You can use it to recover marks." 2318buffer. You can use it to recover marks."
2318 (interactive nil proced-mode) 2319 (interactive "P" proced-mode)
2319 (let (buffer-read-only) 2320 (undo-ignore-read-only arg)
2320 (undo))
2321 (message "Change in Proced buffer undone. 2321 (message "Change in Proced buffer undone.
2322Killed processes cannot be recovered by Emacs.")) 2322Killed processes cannot be recovered by Emacs."))
2323 2323
diff --git a/lisp/simple.el b/lisp/simple.el
index 63c2a665b64..2f9d24812a9 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3577,6 +3577,13 @@ as an argument limits undo to changes within the current region."
3577 (if message 3577 (if message
3578 (message "%s" message)))) 3578 (message "%s" message))))
3579 3579
3580(defun undo-ignore-read-only (&optional arg)
3581 "Perform `undo', ignoring the buffer's read-only status.
3582A numeric ARG serves as a repeat count."
3583 (interactive "P")
3584 (let ((inhibit-read-only t))
3585 (undo arg)))
3586
3580(defun buffer-disable-undo (&optional buffer) 3587(defun buffer-disable-undo (&optional buffer)
3581 "Make BUFFER stop keeping undo information. 3588 "Make BUFFER stop keeping undo information.
3582No argument or nil as argument means do this for the current buffer." 3589No argument or nil as argument means do this for the current buffer."
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 5e219bd1d68..bc05ce2c7fc 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -217,7 +217,7 @@ See also `diff-mode-read-only-map'."
217 "RET" #'diff-goto-source 217 "RET" #'diff-goto-source
218 "<mouse-2>" #'diff-goto-source 218 "<mouse-2>" #'diff-goto-source
219 "o" #'diff-goto-source ; other-window 219 "o" #'diff-goto-source ; other-window
220 "<remap> <undo>" #'diff-undo 220 "<remap> <undo>" #'undo-ignore-read-only
221 221
222 ;; The foregoing commands don't affect buffers beyond this one. 222 ;; The foregoing commands don't affect buffers beyond this one.
223 ;; The following command is the only one that has a single-letter 223 ;; The following command is the only one that has a single-letter
@@ -2815,12 +2815,6 @@ Call FUN with two args (BEG and END) for each hunk."
2815(defun diff--overlay-auto-delete (ol _after _beg _end &optional _len) 2815(defun diff--overlay-auto-delete (ol _after _beg _end &optional _len)
2816 (delete-overlay ol)) 2816 (delete-overlay ol))
2817 2817
2818(defun diff-undo (&optional arg)
2819 "Perform `undo', ignoring the buffer's read-only status."
2820 (interactive "P")
2821 (let ((inhibit-read-only t))
2822 (undo arg)))
2823
2824;;;###autoload 2818;;;###autoload
2825(defcustom diff-add-log-use-relative-names nil 2819(defcustom diff-add-log-use-relative-names nil
2826 "Use relative file names when generating ChangeLog skeletons. 2820 "Use relative file names when generating ChangeLog skeletons.