* bug#1238: 23.0.60; ido-write-file makes it easy to overwrite files unintentionally
@ 2008-10-24 10:53 andreas.amann
2010-11-13 14:57 ` bug#1238: " Ryan Twitchell
0 siblings, 1 reply; 3+ messages in thread
From: andreas.amann @ 2008-10-24 10:53 UTC (permalink / raw)
To: emacs-pretest-bug
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]
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#1238: ido-write-file makes it easy to overwrite files unintentionally
2008-10-24 10:53 bug#1238: 23.0.60; ido-write-file makes it easy to overwrite files unintentionally andreas.amann
@ 2010-11-13 14:57 ` Ryan Twitchell
2010-12-17 10:56 ` Chong Yidong
0 siblings, 1 reply; 3+ messages in thread
From: Ryan Twitchell @ 2010-11-13 14:57 UTC (permalink / raw)
To: 1238
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#1238: ido-write-file makes it easy to overwrite files unintentionally
2010-11-13 14:57 ` bug#1238: " Ryan Twitchell
@ 2010-12-17 10:56 ` Chong Yidong
0 siblings, 0 replies; 3+ messages in thread
From: Chong Yidong @ 2010-12-17 10:56 UTC (permalink / raw)
To: Ryan Twitchell; +Cc: 1238, andreas.amann
Ryan Twitchell <metatheorem@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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-12-17 10:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-24 10:53 bug#1238: 23.0.60; ido-write-file makes it easy to overwrite files unintentionally andreas.amann
2010-11-13 14:57 ` bug#1238: " Ryan Twitchell
2010-12-17 10:56 ` Chong Yidong
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).