[Top][All Lists]

[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:10:39 -0700

>     It's best to separate the concerns when analyzing the 
>     problem you ran into: consider both (a) the command
>     behavior and (b) the key bindings. Whatever the
>     binding, is `find-alternate-file' dangerous? If so, then 
>     let's fix its behavior.
> It is somewhat dangerous _because_ it has a key binding.

No, it was claimed that the command's behavior itself is dangerous, which means
regardless of how it is called. The fact that it has a key binding that might
cause it to be called unintentionally could be a further risk. It's still best
to analyze both issues.

> We could try to fix its behavior, but maybe eliminating the
> binding is easier.

That will not take care of the danger from the command behavior itself, if there
is such.

AFAICT, the danger (both dangers, in fact), comes from `kill-buffer' not warning
and asking for confirmation in the case of a *shell* buffer (or other non-file
buffer). If that happened, then there would be no problem whatsoever, IIUC. It
warns about modified file buffers, but not modified buffers in general. The OP
has, in effect, pointed out that there can be important data in non-file

It is not something special in `find-alternate-file' that is the problem in this
regard; it is the fact that it kills the buffer with no warning - and it is just
its call of `kill-buffer' that is the culprit there.

Removing or changing the `C-x C-v' key binding is, I think, mostly beside the
point. If `C-x k' has the same problem, then mistaking a `k' for a `v' presents
the same problem as mistaking a `C-v' for a `v' or for a `C-f'. We've heard that
the OP has the same problem mistakenly typing either `C-x C-v' or `C-x C-f'
instead of `C-x v'. How many other keys are similar enough to a buffer-killing
key sequence to present essentially the same problem?

If the real problem is the danger of losing data because `kill-buffer' doesn't
warn when killing a non-file buffer such as *shell*, then that's what should be
addressed. It doesn't make sense to ignore that problem and just start moving
keys around, to try to avoid inadvertently killing the buffer in one situation
or another.

>     Fully half the reason I use `find-alternate-file' is to 
>     _kill_ the current buffer (mistaken file visit or not).
>     I use `C-x C-f' when I want to keep the current buffer,
>     and `C-x C-v' when I want to kill it.
> Of course, getting rid of the current buffer is why one uses it.

So we agree about that. I thought you were suggesting that a history list
somehow provided the same utility as `C-x C-v'.

> The question is whether it is sufficienty easier than C-x C-k RET and M-p
> to justify giving it a key binding.

(I think you mean `C-x k', not `C-x C-k'; if not, you've lost me.)

FWIW, as far as I'm concerned, the history is pretty irrelevant here. I don't
use `C-x C-v' to necessarily (or even usually) change to a file name that is on
the history. I use it to visit any file whatsoever (or Dired).

(Yes, some of the time I use it because I typed the wrong character and hit RET,
but that's not my typical use of it (in spite of the command name). And even in
that case, there is nothing particular that the history offers in this regard -
nothing implies that the file name I really wanted to type has been accessed

Yes, a user can always use `C-x k' and then `C-x C-f' or whatever. But `C-x k'
apparently doesn't warn either. The only safety advantage in doing that instead
of `C-x C-v' is if you assume that `C-x k' is less likely to be invoked
accidentally. Certainly, there is (at least somewhat) less likelihood of
confusion with `C-x v <whatever>'. But confusion with other keys?

The danger of losing "megabytes of data" in *shell* is not logically related to
the choice of using a version-control command. _Any_ accidental invocation of
_any_ command that kills the *shell* buffer (or another modified buffer) without
warning presents the same problem. Confusing `C-x k' with `C-x C-k <whatever>'
(the kmacro prefix) is every bit as problematic as confusing `C-x C-v' with `C-x
v <whatever>' (the version-control prefix), I would think.

I think the question comes down to whether `kill-buffer' should warn in such a
context (modified buffer) or not. If not, then the problem remains, regardless
of any key shuffling we might do. If so, then that's the problem to fix.

reply via email to

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