emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

find-file for file that was deleted, when visiting buffer still exists


From: Drew Adams
Subject: find-file for file that was deleted, when visiting buffer still exists
Date: Sat, 3 Mar 2007 09:29:49 -0800

This has been standard Emacs behavior for a long time, but I wonder about
it.

1. Visit a file `foo' in a buffer. Close the window, but don't kill the
buffer.

2. Delete file `foo' (e.g. `delete-file' or some other way that doesn't also
kill the buffer).

3. `C-x C-f foo'

This raises an error saying that the file no longer exists.

[The error message says nothing about the existing buffer, BTW. If a user
forgets that the buffer still exists, then s?he might have a difficult time
understanding this message and why s?he can't use `C-x C-f' to create a new
file named `foo'.]

I wonder if this is really what Emacs should always do in this context.
IIUC, the real problem is that the buffer still exists, and Emacs can't know
what the user wants to do in this case. S?he might want to save the buffer.
S?he might want to kill the buffer and create a new file-visiting buffer
with the same name. There are perhaps additional possibilities.

This error is raised by `find-file-noselect', which is not a command, so not
much is known about the user context at this point - the function might even
be run in batch. IOW, the error is raised at a fairly low level, in a
function that is called in many different ways.

I wonder if it wouldn't be good to try to deal with the interactive cases by
asking the user what to do. That is, try to handle the error by passing it
up to the command (`find-file' etc.) whenever the command is called
interactively.

Perhaps a dialog something like this:

 Buffer `foo' was visiting file `foo', which no longer exists.
 Choose one:

 s RET - Save buffer `foo' as file `foo'
 k RET - Visit a new, empty file in buffer `foo'
 RET   - Do nothing

WDOT? Am I missing something important that argues for the current behavior
even for interactive use? If my suggestion is a bad idea, can we at least
improve the error message, so that it mentions the existing buffer?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]