unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Karl Fogel <kfogel@red-bean.com>
Cc: emacs-devel@gnu.org
Subject: Re: Curious behavior in find-alternate-file.
Date: Tue, 08 Sep 2009 12:10:25 -0400	[thread overview]
Message-ID: <jwvhbvdberd.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87ws4e74lj.fsf@red-bean.com> (Karl Fogel's message of "Fri, 04 Sep 2009 18:00:24 -0400")

> 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)





  parent reply	other threads:[~2009-09-08 16:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-04 22:00 Curious behavior in find-alternate-file Karl Fogel
2009-09-05  7:03 ` Andreas Schwab
2009-09-08 16:10 ` Stefan Monnier [this message]
2009-09-08 21:43   ` Karl Fogel

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=jwvhbvdberd.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=kfogel@red-bean.com \
    /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).