GNU bug report logs - #1238
23.0.60; ido-write-file makes it easy to overwrite files unintentionally

Previous Next

Package: emacs;

Reported by: "andreas.amann" <andreas.amann <at> tyndall.ie>

Date: Fri, 24 Oct 2008 11:00:02 UTC

Severity: wishlist

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ryan Twitchell <metatheorem <at> gmail.com>
To: 1238 <at> debbugs.gnu.org
Subject: bug#1238: ido-write-file makes it easy to overwrite files unintentionally
Date: Sat, 13 Nov 2010 09:57:42 -0500
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-file<return>new-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






This bug report was last modified 14 years and 164 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.