Mercurial > emacs
changeset 82194:06241457c4f0
(wdired-exit): New function.
(wdired-mode-map): Bind C-x C-q to wdired-exit.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Sun, 29 Jul 2007 09:17:30 +0000 |
parents | 6037be8575c3 |
children | 69abb81564e4 |
files | lisp/wdired.el |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/wdired.el Sat Jul 28 20:03:40 2007 +0000 +++ b/lisp/wdired.el Sun Jul 29 09:17:30 2007 +0000 @@ -175,6 +175,7 @@ (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 @@ (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".