From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Curious behavior in find-alternate-file. Date: Tue, 08 Sep 2009 12:10:25 -0400 Message-ID: References: <87ws4e74lj.fsf@red-bean.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1252426467 15317 80.91.229.12 (8 Sep 2009 16:14:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Sep 2009 16:14:27 +0000 (UTC) Cc: emacs-devel@gnu.org To: Karl Fogel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 08 18:14:20 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ml3Kk-0006GY-6e for ged-emacs-devel@m.gmane.org; Tue, 08 Sep 2009 18:14:18 +0200 Original-Received: from localhost ([127.0.0.1]:58874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ml3Kj-0003dZ-Hk for ged-emacs-devel@m.gmane.org; Tue, 08 Sep 2009 12:14:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ml3H9-0001Ks-6l for emacs-devel@gnu.org; Tue, 08 Sep 2009 12:10:35 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ml3H4-0001F4-Hq for emacs-devel@gnu.org; Tue, 08 Sep 2009 12:10:34 -0400 Original-Received: from [199.232.76.173] (port=35749 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ml3H4-0001El-07 for emacs-devel@gnu.org; Tue, 08 Sep 2009 12:10:30 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:50801) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ml3H3-0002Mt-H9 for emacs-devel@gnu.org; Tue, 08 Sep 2009 12:10:29 -0400 Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id n88GAPQj009510; Tue, 8 Sep 2009 12:10:25 -0400 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 5E2823A8F3; Tue, 8 Sep 2009 12:10:25 -0400 (EDT) In-Reply-To: <87ws4e74lj.fsf@red-bean.com> (Karl Fogel's message of "Fri, 04 Sep 2009 18:00:24 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-NAI-Spam-Level: X-NAI-Spam-Score: 0.5 X-NAI-Spam-Rules: 2 Rules triggered PHONE_877=0.5, RV3358=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115133 Archived-At: > 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)