[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#1238: ido-write-file makes it easy to overwrite files unintentionall
From: |
Ryan Twitchell |
Subject: |
bug#1238: ido-write-file makes it easy to overwrite files unintentionally |
Date: |
Sat, 13 Nov 2010 09:57:42 -0500 |
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 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#1238: ido-write-file makes it easy to overwrite files unintentionally,
Ryan Twitchell <=