unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: rms@gnu.org
Cc: dann@ics.uci.edu, emacs-devel@gnu.org
Subject: Re: wdired-change-to-wdired-mode needs a key binding in dired-mode
Date: Fri, 27 Jul 2007 23:59:48 +0300	[thread overview]
Message-ID: <87myxh5yba.fsf@jurta.org> (raw)
In-Reply-To: <E1IE6gJ-0005t5-3D@fencepost.gnu.org> (Richard Stallman's message of "Thu\, 26 Jul 2007 12\:59\:19 -0400")

>     Now, what should C-x C-q do in wdired mode?
>     How about this:
>
>     if not buffer-modified-p
>        switch back to dired-mode
>     else
>        print a warning that the user needs to either save her changes or
>        cancel them
>
> I prefer the later suggestion to ask whether to save or cancel them.

The following patch implements this:

Index: lisp/wdired.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/wdired.el,v
retrieving revision 1.26
diff -c -r1.26 wdired.el
*** lisp/wdired.el	26 Jul 2007 05:26:37 -0000	1.26
--- lisp/wdired.el	27 Jul 2007 20:54:57 -0000
***************
*** 175,180 ****
--- 175,181 ----
      (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,428 ****
--- 424,445 ----
    (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".

-- 
Juri Linkov
http://www.jurta.org/emacs/

  reply	other threads:[~2007-07-27 20:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-24  2:16 wdired-change-to-wdired-mode needs a key binding in dired-mode Dan Nicolaescu
2007-07-24  5:31 ` Mathias Dahl
2007-07-24  6:19   ` Thien-Thi Nguyen
2007-07-24  8:46     ` joakim
2007-07-24  9:55     ` Mathias Dahl
2007-07-24 22:17     ` Richard Stallman
2007-07-24 23:06       ` Dan Nicolaescu
2007-07-25 20:11         ` Richard Stallman
2007-07-26  2:12           ` Dan Nicolaescu
2007-07-26 16:59             ` Richard Stallman
2007-07-25 20:57         ` Juri Linkov
2007-07-26  0:44           ` Stefan Monnier
2007-07-26  2:09             ` Dan Nicolaescu
2007-07-26  8:54               ` Juri Linkov
2007-07-26 16:59               ` Richard Stallman
2007-07-27 20:59                 ` Juri Linkov [this message]
2007-07-29  2:22                   ` Richard Stallman
2007-07-29  9:19                     ` Juri Linkov
2007-07-29 22:02                       ` Dan Nicolaescu
2007-07-30 20:47                         ` Richard Stallman
2007-07-27 20:59     ` Juri Linkov
2007-07-27 21:50       ` Dan Nicolaescu
2007-07-27 22:02         ` Leo
2007-07-28  3:53       ` Stefan Monnier
2007-07-28  9:14         ` Juri Linkov
2007-07-29  2:22       ` Richard Stallman
2007-07-29  9:20         ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87myxh5yba.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).