diff options
author | Juri Linkov <juri@jurta.org> | 2007-07-29 09:17:30 +0000 |
---|---|---|
committer | Juri Linkov <juri@jurta.org> | 2007-07-29 09:17:30 +0000 |
commit | f8f67141f10e299501ac66b496c6647b67a9d3d3 (patch) | |
tree | 70e0da4e3d9dae7d20592a30745a5b2aa23a1e03 /lisp/wdired.el | |
parent | a0247dcf3990ef954108d39d913d9cccc3a1b4fe (diff) | |
download | emacs-f8f67141f10e299501ac66b496c6647b67a9d3d3.tar.gz |
(wdired-exit): New function.
(wdired-mode-map): Bind C-x C-q to wdired-exit.
Diffstat (limited to 'lisp/wdired.el')
-rw-r--r-- | lisp/wdired.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/wdired.el b/lisp/wdired.el index 0abb8647ce0..960d8990983 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el @@ -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". |