GNU bug report logs -
#1238
23.0.60; ido-write-file makes it easy to overwrite files unintentionally
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1238 in the body.
You can then email your comments to 1238 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#1238
; Package
emacs
.
Full text and
rfc822 format available.
Acknowledgement sent to
"andreas.amann" <andreas.amann <at> tyndall.ie>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
I am often using the C-x C-w shortcut to save a buffer into a
different directory, usually without changing it's name.
The standard write-file works well for this, since after selecting the
appropriate directory, I simply hit return, and the file gets saved
where I want it, without a change in the name by default.
However, since I switched to ido-mode and ido-write-file I found that
after navigating to a directory, which does not contain any
subdirectories, the first filename in that directory gets selected as
the filename, into which to write the contents of the active
buffer. This has several times already caused me to overwrite a file
with the current buffer by accident, since after selecting the
appropriate directory, I was not noticing the selection and wrongly
assumed that emacs would simply write the file into this directory
with the old filename. After hitting return however the active buffer
would be written into this first file of the directory.
I know I can simply work around this by binding C-x C-w to write-file,
but in my opinion, ido-write-file should be changed in a way which
makes it more difficult to overwrite a file. I would expect that C-x
C-w is used for more often to create a new file, than to overwrite an
existing one. Therefore in my opinion the current behaviour of
ido-write-file to select the first file in the directory only serves
a minority of use-cases.
In GNU Emacs 23.0.60.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2008-10-20 on lnx0015f2465ec6
Windowing system distributor `The X.Org Foundation', version 11.0.10300000
configured using `configure '--prefix=/home/aamann/local/emacs-cvs' 'LDFLAGS=-L/home/aamann/local/lib64' 'CPPFLAGS=-I/home/aamann/local/include''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_IE.utf8
value of $XMODIFIERS: @im=none
locale-coding-system: utf-8-unix
default-enable-multibyte-characters: t
Major mode: Lisp Interaction
Minor modes in effect:
shell-dirtrack-mode: t
tooltip-mode: t
tool-bar-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
global-auto-composition-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
M-x i d o - m o d <tab> <return> C-x C-w C-g M-x w
r i t e - f <tab> <return> C-g M-x i d o - w r i <tab>
<return> C-g C-x C-w C-g C-h C-b C-h b C-x o C-s w
r i t e <up> <up> <down> <down> <left> <left> <left>
C-x o M-x w e m <backspace> <backspace> <backspace>
e m a c s <tab> b <tab> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
b u g <tab> <tab> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> r e p <tab> o r <tab> <return>
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Ido mode enabled
Quit [4 times]
Type C-x 1 to delete the help window, C-M-v to scroll help.
Mark saved where search started
Making completion list... [2 times]
Severity set to 'wishlist' from 'normal'
Request was from
Chong Yidong <cyd <at> stupidchicken.com>
to
control <at> debbugs.gnu.org
.
(Thu, 24 Jun 2010 18:24:03 GMT)
Full text and
rfc822 format available.
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#1238
; Package
emacs
.
(Sat, 13 Nov 2010 14:53:01 GMT)
Full text and
rfc822 format available.
Message #10 received at 1238 <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#1238
; Package
emacs
.
(Fri, 17 Dec 2010 10:51:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 1238 <at> debbugs.gnu.org (full text, mbox):
Ryan Twitchell <metatheorem <at> gmail.com> writes:
> 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:
>
> The function ido-file-internal uses plain old write-file to carry out
> this action:
>
> 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.
Sounds reasonable. I've committed a fix following your suggestion;
thanks.
bug closed, send any further explanations to "andreas.amann" <andreas.amann <at> tyndall.ie>
Request was from
Chong Yidong <cyd <at> stupidchicken.com>
to
control <at> debbugs.gnu.org
.
(Fri, 17 Dec 2010 10:51:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 14 Jan 2011 12:24:04 GMT)
Full text and
rfc822 format available.
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.