Commit f8f67141 authored by Juri Linkov's avatar Juri Linkov
Browse files

(wdired-exit): New function.

(wdired-mode-map): Bind C-x C-q to wdired-exit.
parent a0247dcf
......@@ -175,6 +175,7 @@ program `dired-chmod-program', which must exist."
(define-key map "\C-c\C-c" 'wdired-finish-edit)
(define-key map "\C-c\C-k" 'wdired-abort-changes)
(define-key map "\C-c\C-[" 'wdired-abort-changes)
(define-key map "\C-x\C-q" 'wdired-exit)
(define-key map "\C-m" 'ignore)
(define-key map "\C-j" 'ignore)
(define-key map "\C-o" 'ignore)
......@@ -423,6 +424,22 @@ non-nil means return old filename."
(set-buffer-modified-p nil)
(setq buffer-undo-list nil))
(defun wdired-exit ()
"Exit wdired and return to dired mode.
Just return to dired mode if there are no changes. Otherwise,
ask a yes-or-no question whether to save or cancel changes,
and proceed depending on the answer."
(interactive)
(if (buffer-modified-p)
(if (y-or-n-p (format "Buffer %s modified; save changes? "
(current-buffer)))
(wdired-finish-edit)
(wdired-abort-changes))
(wdired-change-to-dired-mode)
(set-buffer-modified-p nil)
(setq buffer-undo-list nil)
(message "(No changes need to be saved)")))
;; Rename a file, searching it in a modified dired buffer, in order
;; to be able to use `dired-do-create-files-regexp' and get its
;; "benefits".
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment