From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Rogers Newsgroups: gmane.emacs.devel Subject: Re: C-x C-v considered harmful Date: Wed, 1 Jul 2009 23:10:09 -0400 Message-ID: <19020.9489.731182.788978@rgr.rgrjr.com> References: <19020.2798.523236.406366@rgr.rgrjr.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1246504235 14609 80.91.229.12 (2 Jul 2009 03:10:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 2 Jul 2009 03:10:35 +0000 (UTC) Cc: emacs-devel@gnu.org To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 02 05:10:28 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 1MMCgr-0001Rq-Kl for ged-emacs-devel@m.gmane.org; Thu, 02 Jul 2009 05:10:25 +0200 Original-Received: from localhost ([127.0.0.1]:54596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MMCgq-0002rO-Ua for ged-emacs-devel@m.gmane.org; Wed, 01 Jul 2009 23:10:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MMCgm-0002pQ-3Q for emacs-devel@gnu.org; Wed, 01 Jul 2009 23:10:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MMCgh-0002iq-GD for emacs-devel@gnu.org; Wed, 01 Jul 2009 23:10:19 -0400 Original-Received: from [199.232.76.173] (port=58031 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MMCgh-0002iZ-Bd for emacs-devel@gnu.org; Wed, 01 Jul 2009 23:10:15 -0400 Original-Received: from rgrjr.com ([216.146.47.5]:37877) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MMCgg-0005Iq-QC for emacs-devel@gnu.org; Wed, 01 Jul 2009 23:10:15 -0400 Original-Received: from rgrjr.dyndns.org (c-66-30-196-77.hsd1.ma.comcast.net [66.30.196.77]) by rgrjr.com (Postfix on CentOS) with ESMTP id 3A4EC16013A for ; Thu, 2 Jul 2009 03:10:14 +0000 (UTC) Original-Received: (qmail 26574 invoked by uid 89); 2 Jul 2009 03:10:13 -0000 Original-Received: from unknown (HELO rgr.rgrjr.com) (192.168.57.1) by home with SMTP; 2 Jul 2009 03:10:13 -0000 Original-Received: by rgr.rgrjr.com (Postfix, from userid 500) id E8E9E4862E; Wed, 1 Jul 2009 23:10:09 -0400 (EDT) In-Reply-To: X-Mailer: VM viewmail-600 under 23.1.50.1 (i686-pc-linux-gnu) 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:111887 Archived-At: From: Miles Bader Date: Thu, 02 Jul 2009 11:39:17 +0900 Bob Rogers writes: > 1. Bind find-alternate-file to something different. > 2. Add a "[Confirm]" step if nonexistent, as for selecting files or > buffers with confirm-nonexistent-file-or-buffer set to t. > 3. Do not bind find-alternate-file to anything at all. How about: 4. Make find-alternate-file use a yes-or-no-p confirmation prompt if the buffer has no associated file. My guess is that the vast majority of uses of find-alternate-file are replacing one file buffer with another, and that intentionally replacing "special" buffers is very rare. Agreed; I like this best. Please find a patch below that broadens the case for modified files to cover non-files as well. If there are specific modes or buffers for which "replacement" _is_ commonly used, then there could be a variable to tell find-alternate-file not to confirm that buffer (and a user could set the global default value of that variable to turn off all confirmation) -Miles Here is the way find-alternate-file describes itself: Find file FILENAME, select its buffer, kill previous buffer. If the current buffer now contains an empty file that you just visited (presumably by mistake), use this command to visit the file you really want. Given this perspective, the replace-a-non-file-buffer use case would seem to be rare -- and always asking about non-file buffers makes sense. -- Bob ------------------------------------------------------------------------ Index: lisp/files.el =================================================================== RCS file: /sources/emacs/emacs/lisp/files.el,v retrieving revision 1.1052 diff -c -r1.1052 files.el *** lisp/files.el 22 Jun 2009 07:02:08 -0000 1.1052 --- lisp/files.el 2 Jul 2009 03:02:48 -0000 *************** *** 1465,1471 **** t))) (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; kill anyway? " (buffer-name))) (unless (yes-or-no-p "Kill and replace the buffer without saving it? ") --- 1465,1472 ---- t))) (unless (run-hook-with-args-until-failure 'kill-buffer-query-functions) (error "Aborted")) ! (when (or (not (buffer-file-name)) ! (buffer-modified-p)) (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? ")