unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* find-file for file that was deleted, when visiting buffer still exists
@ 2007-03-03 17:29 Drew Adams
  2007-03-03 18:02 ` Mathias Dahl
  2007-03-05  2:55 ` Richard Stallman
  0 siblings, 2 replies; 6+ messages in thread
From: Drew Adams @ 2007-03-03 17:29 UTC (permalink / raw)
  To: Emacs-Devel

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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: find-file for file that was deleted, when visiting buffer still exists
  2007-03-03 17:29 find-file for file that was deleted, when visiting buffer still exists Drew Adams
@ 2007-03-03 18:02 ` Mathias Dahl
  2007-03-05  2:55 ` Richard Stallman
  1 sibling, 0 replies; 6+ messages in thread
From: Mathias Dahl @ 2007-03-03 18:02 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emacs-Devel

> 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.
> ...
> 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

What about

b RET - Switch to buffer `foo'

I think that it would be useful to notify the user of the existing
buffer. Who knows,
maybe the file was deleted by mistake, which means the user is lucky that Emacs
still has a copy of it. Unfortunately he might not find that out because of how
Emacs currently handles this scenario.

I agree with Drew, it would be nice with some changes here. Now or later.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: find-file for file that was deleted, when visiting buffer still exists
  2007-03-03 17:29 find-file for file that was deleted, when visiting buffer still exists Drew Adams
  2007-03-03 18:02 ` Mathias Dahl
@ 2007-03-05  2:55 ` Richard Stallman
  2007-03-05  4:57   ` Drew Adams
  2007-03-05  7:14   ` Mathias Dahl
  1 sibling, 2 replies; 6+ messages in thread
From: Richard Stallman @ 2007-03-05  2:55 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

    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'

Perhaps it should visit the buffer foo, and give a warning that the
file no longer exists.  That seems better to me.  Does anyone
disagree?

(To ask what to do would be surprising and inconvenient.)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: find-file for file that was deleted, when visiting buffer still exists
  2007-03-05  2:55 ` Richard Stallman
@ 2007-03-05  4:57   ` Drew Adams
  2007-03-05 21:50     ` Richard Stallman
  2007-03-05  7:14   ` Mathias Dahl
  1 sibling, 1 reply; 6+ messages in thread
From: Drew Adams @ 2007-03-05  4:57 UTC (permalink / raw)
  To: emacs-devel

>     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'
>
> Perhaps it should visit the buffer foo, and give a warning that the
> file no longer exists.  That seems better to me.  Does anyone
> disagree?

Yes, that sounds good.

Should find-file-noselect do that directly? Always, or only when called from
a command initiated interactively?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: find-file for file that was deleted, when visiting buffer still exists
  2007-03-05  2:55 ` Richard Stallman
  2007-03-05  4:57   ` Drew Adams
@ 2007-03-05  7:14   ` Mathias Dahl
  1 sibling, 0 replies; 6+ messages in thread
From: Mathias Dahl @ 2007-03-05  7:14 UTC (permalink / raw)
  To: rms; +Cc: Drew Adams, emacs-devel

> Perhaps it should visit the buffer foo, and give a warning that the
> file no longer exists.  That seems better to me.

Sounds good to me.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: find-file for file that was deleted, when visiting buffer still exists
  2007-03-05  4:57   ` Drew Adams
@ 2007-03-05 21:50     ` Richard Stallman
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2007-03-05 21:50 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

    > Perhaps it should visit the buffer foo, and give a warning that the
    > file no longer exists.  That seems better to me.  Does anyone
    > disagree?

I did that.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-05 21:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-03 17:29 find-file for file that was deleted, when visiting buffer still exists Drew Adams
2007-03-03 18:02 ` Mathias Dahl
2007-03-05  2:55 ` Richard Stallman
2007-03-05  4:57   ` Drew Adams
2007-03-05 21:50     ` Richard Stallman
2007-03-05  7:14   ` Mathias Dahl

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).