From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ryan Twitchell Newsgroups: gmane.emacs.bugs Subject: bug#1238: ido-write-file makes it easy to overwrite files unintentionally Date: Sat, 13 Nov 2010 09:57:42 -0500 Message-ID: <4CDEA766.50302@gmail.com> References: <200810241053.m9OAr0P8026782@localhost.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1289661374 5181 80.91.229.12 (13 Nov 2010 15:16:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 13 Nov 2010 15:16:14 +0000 (UTC) To: 1238@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 13 16:16:07 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PHHpB-0007v5-G3 for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Nov 2010 16:16:07 +0100 Original-Received: from localhost ([127.0.0.1]:60969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PHHon-0004Rw-S2 for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Nov 2010 10:15:05 -0500 Original-Received: from [140.186.70.92] (port=45161 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PHHoW-000377-Ie for bug-gnu-emacs@gnu.org; Sat, 13 Nov 2010 10:15:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PHHnl-000569-5f for bug-gnu-emacs@gnu.org; Sat, 13 Nov 2010 10:14:02 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PHHnk-000565-Ub for bug-gnu-emacs@gnu.org; Sat, 13 Nov 2010 10:14:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PHHTR-0001tl-Ur; Sat, 13 Nov 2010 09:53:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <200810241053.m9OAr0P8026782@localhost.localdomain> Resent-From: Ryan Twitchell Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Nov 2010 14:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 1238 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 1238-submit@debbugs.gnu.org id=B1238.12896599777291 (code B ref 1238); Sat, 13 Nov 2010 14:53:01 +0000 Original-Received: (at 1238) by debbugs.gnu.org; 13 Nov 2010 14:52:57 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PHHTM-0001tY-Tx for submit@debbugs.gnu.org; Sat, 13 Nov 2010 09:52:57 -0500 Original-Received: from mail-vw0-f44.google.com ([209.85.212.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PHHTL-0001tT-2V for 1238@debbugs.gnu.org; Sat, 13 Nov 2010 09:52:55 -0500 Original-Received: by vws8 with SMTP id 8so995064vws.3 for <1238@debbugs.gnu.org>; Sat, 13 Nov 2010 06:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=5Vs8yomfxVVKfcHzGoHdTDFjhW7Bi6ifZ7p+WViqVKE=; b=aNNwuqG8u+tjuRy6IG/vkazb3kuLGXJaH56HRsS95ZwhaLijRA09i4bL7rQQfU8rJo 23TtckE4avv6lllnpgcBmmQilfN/uCfMoYMisTthpVdUHNEpbzYaYvruYEAykgzPKI1v acEbcDWZDoFdMV4UTmhuR4POqenQKlBb8IbSw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=v+Bv7gisAh6XxB0/gCeBKllg5WyvMPf6wB5XoJPodzpQk/bUsUqk3FX3m2RfyiQdAl Ojar/woOVBTrES8tHM4vHFSkF1QakAuZMVy2LD41m0BDwa8ZF1vE15QvF0ekfPj8HXVf RFS41i1UbXbjswQKF7bpg7uqHM74pr6KeIwTY= Original-Received: by 10.220.189.11 with SMTP id dc11mr903470vcb.39.1289660266033; Sat, 13 Nov 2010 06:57:46 -0800 (PST) Original-Received: from [192.168.1.28] (cpe-74-74-249-54.rochester.res.rr.com [74.74.249.54]) by mx.google.com with ESMTPS id o17sm1639698vbi.2.2010.11.13.06.57.44 (version=SSLv3 cipher=RC4-MD5); Sat, 13 Nov 2010 06:57:45 -0800 (PST) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101031 Lightning/1.0b3pre Thunderbird/3.1.6 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 13 Nov 2010 09:53:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:41551 Archived-At: I encountered this problem independently in version 23.2.1, and think I have a very simple fix. As a drop in replacement for write-file, ido-write-file does not prompt the user for confirmation when overwriting an existing file: Steps to reproduce: $ emacs -Q M-x emacs-version "GNU Emacs 23.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) of 2010-11-07 on falconsrevenge" M-x ido-mode C-x C-f new-file ...editing C-x C-s C-x C-b new-buffer ...editing C-x C-w new-file OR M-x ido-write-filenew-file ...prompt expected here, but new-file is overwritten. The function ido-file-internal uses plain old write-file to carry out this action: Line 2382: ((eq method 'write) (ido-record-work-file filename) (setq default-directory ido-current-directory) (setq filename (concat ido-current-directory filename)) (ido-record-command 'write-file filename) (add-to-history 'file-name-history filename) (ido-record-work-directory) (write-file filename)) ido functions are primarily for interactive use, so it seems safe to pass a true value to write-file's CONFIRM arg (on the last line above) to always enable prompting: (write-file filename t) A quick test confirmed this change added the expected behavior. Ryan Twitchell