* Curious behavior in find-alternate-file.
@ 2009-09-04 22:00 Karl Fogel
2009-09-05 7:03 ` Andreas Schwab
2009-09-08 16:10 ` Stefan Monnier
0 siblings, 2 replies; 4+ messages in thread
From: Karl Fogel @ 2009-09-04 22:00 UTC (permalink / raw)
To: emacs-devel
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?
-Karl
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Curious behavior in find-alternate-file.
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
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2009-09-05 7:03 UTC (permalink / raw)
To: Karl Fogel; +Cc: emacs-devel
Karl Fogel <kfogel@red-bean.com> writes:
> 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?
That's exactly the behaviour of Emacs between 2002-07-14 and
2007-01-20.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Curious behavior in find-alternate-file.
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
2009-09-08 21:43 ` Karl Fogel
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2009-09-08 16:10 UTC (permalink / raw)
To: Karl Fogel; +Cc: emacs-devel
> 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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Curious behavior in find-alternate-file.
2009-09-08 16:10 ` Stefan Monnier
@ 2009-09-08 21:43 ` Karl Fogel
0 siblings, 0 replies; 4+ messages in thread
From: Karl Fogel @ 2009-09-08 21:43 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> 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?
Well, I wasn't sophisticated enough to use vc-annotate :-), but I saw
Chong's r1.878 via old-fashioned 'cvs log'. I assumed he was watching
the discussion here, and would have said something if there was an
important reason for the behavior, but perhaps that was too optimistic
-- he does get a lot of mail, after all. Should I maybe mail him
personally, or put "ATTN: Chong Yidong" in the subject, or something?
Chong, the relevant recent change is:
lisp/files.el: revision 1.1077
date: 2009-09-05 11:16:49 -0400; author: kfogel; state: Exp;
lines: +6 -6; commitid: RHZgxPghVlEnfv2u;
* lisp/files.el (find-alternate-file): If the old buffer is modified
and visiting a file, behave similarly to `kill-buffer' when killing
it, thus reverting to the pre-1.878 behavior; see
http://lists.gnu.org/archive/html/emacs-devel/2009-09/msg00101.html
for discussion. Also, consult `buffer-file-name' as a variable not
as a function, for consistency with the rest of the code.
-Karl
> 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)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-09-08 21:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-09-08 21:43 ` Karl Fogel
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).