emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Curious behavior in find-alternate-file.


From: Stefan Monnier
Subject: Re: Curious behavior in find-alternate-file.
Date: Tue, 08 Sep 2009 12:10:25 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> While debugging emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=4061,
> I ran across a curious behavior in files.el:`find-alternate-file':

>   (when (and (buffer-modified-p) (buffer-file-name))
>     (if (yes-or-no-p (format "Buffer %s is modified; kill anyway? "
>                            (buffer-name)))
>       (unless (yes-or-no-p "Kill and replace the buffer without saving it? ")
>         (error "Aborted"))
>       (save-buffer)))

> IOW, the user is prompted "Buffer foo is modified; kill anyway? ", and
> if she answers "no", the buffer is... saved and then killed!

> That's not quite the behavior one would expect, given the prompt.  And
> it's different from how regular kill-buffer (C-x k) behaves.  In regular
> kill-buffer, if the buffer is modified and is visiting a file, then
> you're prompted with the same question as above, but if you answer "no"
> the kill is canceled and you're left sitting in the original buffer.

> Here is my proposed behavior:

>   "Buffer foo is modified; save before killing and replacing? "
>      yes ==> save it and proceed to end
>      no  ==> "Kill and replace the buffer without saving it? "
>                yes ==> kill it and proceed to end
>                no  ==> abort

> Any objections if I make it so?

It's always worthwhile to use M-x vc-annotate and then `d' and/or `l' on
the relevant lines, to see how we got there.  In the present case you'll
find the change described below, which indicates that your change
wouldn't be right either.  Maybe Chong remembers what was the motivation
for that change?


-- Stefan


   revision 1.878
   date: 2007-01-20 14:00:10 -0500;  author: cyd;  state: Exp;  lines: +4 -4;
   (find-alternate-file): Revert query message to Emacs 21 version.


--- files.el    6 Jan 2007 21:50:14 -0000       1.877
+++ files.el    20 Jan 2007 19:00:10 -0000      1.878
@@ -1223,11 +1223,11 @@
   (unless (run-hook-with-args-until-failure 'kill-buffer-query-functions)
     (error "Aborted"))
   (when (and (buffer-modified-p) (buffer-file-name))
-    (if (yes-or-no-p (format "Buffer %s is modified; save it first? "
+    (if (yes-or-no-p (format "Buffer %s is modified; kill anyway? "
                             (buffer-name)))
-       (save-buffer)
       (unless (yes-or-no-p "Kill and replace the buffer without saving it? ")
-       (error "Aborted"))))
+         (error "Aborted"))
+      (save-buffer)))
   (let ((obuf (current-buffer))
        (ofile buffer-file-name)
        (onum buffer-file-number)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]