emacs-devel
[Top][All Lists]
Advanced

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

RE: C-x C-v considered harmful


From: Drew Adams
Subject: RE: C-x C-v considered harmful
Date: Sun, 5 Jul 2009 00:13:36 -0700

>    Does `C-x k' warn you the way you would like, when you use 
>    it in a *shell* buffer?  If not, then that is the problem,
>    not something else.
> 
> It does indeed kill the *shell* buffer without prompting,

Then the command-behavior problem has nothing to do with `find-alternate-file',
per se - any buffer-killing command will present the same problem. There remains
the other problem: that of key confusion raising the risk of accidentally using
some buffer-killing command.

> which seems odd, given that it prompts for modified files.
> I notice that this code uses the C equivalent of "(and
> (buffer-modified-p) (buffer-file-name))",

Donc, meme combat.

> though it queries only if interactive,

Yes, as I stated earlier, testing `interactive-p' should probably be part of the
mix. Non-interactive use of a command that kills a buffer should not necessarily
(or usually) query. It is the interactive use that we want to protect against.

> so a case could be made for dropping the the "(buffer-file-name)"
> for symmetry.

(Not just for symmetry.)

At least you and I agree about dropping `buffer-file-name' - dunno about others.

I maintain, however, that the proper test is `(or buffer-read-only
(buffer-modified-p))'. As I mentioned, there are some "modified" buffers that
one doesn't necessarily need to be warned about losing - things like *Buffer
List* and Dired.

The problem here is the concept of buffer "modification". If the aim is to
prevent data loss, then that aim is typically not advanced by not allowing a
modified read-only buffer to be dropped without query.

> But I have never had the problem of invoking "C-x k" by accident
> (that I recall), so I'm not sure such a case ought to be made.

Well, sure, you got stung because you use the version-control prefix, `C-x v', a
lot. If you used the kmacro prefix, `C-x C-k', a lot, then `C-x k' would sting
you. Any way of accidentally invoking any buffer-killing command presents the
same problem.

>    And as you mentioned, `find-alternate-file' tests `(and
>    (buffer-modified-p) (buffer-file-name))'. I agree with you that the
>    problem you are seeing is coming from `(buffer-file-name)' 
>    being nil, and that removing that might be an improvement.
> 
> As far as I am concerned, removing "(buffer-file-name)" would be
> sufficient.

We agree, modulo my wanting to be able to drop modified read-only buffers
without warning. Another way to look at that is that those buffers typically do
not have undo, which is another indication that we don't expect their contents
to be something we want to worry about saving. The proper test is, I think, `(or
buffer-read-only (buffer-modified-p))'.





reply via email to

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