all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ryan Twitchell <metatheorem@gmail.com>
To: 1238@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	[thread overview]
Message-ID: <4CDEA766.50302@gmail.com> (raw)
In-Reply-To: <200810241053.m9OAr0P8026782@localhost.localdomain>

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







  reply	other threads:[~2010-11-13 14:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2010-12-17 10:56   ` bug#1238: " Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CDEA766.50302@gmail.com \
    --to=metatheorem@gmail.com \
    --cc=1238@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.