all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Bob Rogers'" <rogers-emacs@rgrjr.dyndns.org>
Cc: emacs-devel@gnu.org
Subject: RE: C-x C-v considered harmful
Date: Fri, 3 Jul 2009 15:23:51 -0700	[thread overview]
Message-ID: <BEE2845098304E45A9351056EA6A60C7@us.oracle.com> (raw)
In-Reply-To: <19022.27409.779079.636945@rgr.rgrjr.com>

> you may make an advocate of rebinding "C-x C-v" of me yet.  ;-}

I would sooner see a key-binding change for either `find-alternate-file' or the
vc stuff than I would see an unnecessary modification of the command behavior.
If key-binding confusion is the problem, then the solution is a key-binding
change. If, on the other hand, the command `find-alternate-file' is itself
inherently dangerous, then yes, the command behavior should be altered.

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.
If not, then if there is a problem caused by key-binding confusion, then change
one of the two bindings that people (fingers) confuse.

To be clear, I don't have a big problem with changing the binding of
`find-alternate-file', assuming the new binding is not something far-fetched. I
do think it's important to have a relatively easy-to-use and easily discovered
binding for this, because I consider the command useful. Apparently, some users
who might be taking advantage of it have never learned that it exists. That's
too bad.

And I don't agree with Richard that having a history list obviates the
usefulness of `find-alternate-file':

R> But that is not much of an advantage nowadays, because you can
R> get the mistaken file name via the minibuffer history.

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. I wouldn't have thought I
was alone in that, but I'm beginning to get the impression that I might be.

> > But let me also turn this around:  Out of the last X 
> > times you can remember using C-x C-v, how many of those
> > invocations were in a non-file buffer?  In other words,
> > how likely is it, really, that you might be faced with a
> > new prompt, and be forced to deal with it?
> 
>   1. Personally? I use `C-x C-v' _all_ of the time to simultaneously
>   (a) kill the current buffer - whatever its type (file or non-file)
>   and (b) visit a file or Dired. All of the time.
> 
> Yes, but I asked for numbers -- even very crude ones -- and 
> you give me nothing to make me believe that you would actually
> be affected by this change more than once in a great while.

"_All_ of the time" does not suggest "once in a great while" - at least that was
not my intention in using those words.

If I had to guess a number, I'd guess between X/3 and X/2. FWIW, that's the same
guess I'd make for the buffers I use in general: maybe 2/3 are file buffers.
Just a guess. I do not use `C-x C-v' any more or any less depending on the type
of buffer to be killed, as I already stated.

(Yes, when switching from a file buffer, `find-alternate-file' presents an
additional advantage, since the file to be visited is typically in the same
directory and sometimes has a similar file name. But that is an advantage
relative to other ways to visit a file (e.g. `C-x C-f'); it is not an advantage
relative to switching from a non-file buffer.) 

> how about another alternative:
> 
>    6.  Query only if the old current buffer is a modified buffer,
>        offering to save only for file buffers, and aborting the kill
>        otherwise.  The behavior would change only for 
>        modified non-file buffers (which does include *shell* buffers,
>        but not most temp buffers), and makes it similar to its
>        behavior up to 1994.
> 
> How about it?

Yes, but I think I would prefer `(or buffer-read-only (buffer-modified-p))'.

Killing read-only buffers such as Dired and *Buffer List* that might be modified
(e.g. markings) should not bother one by querying. That would likely be my
preference, but I can see that it might be debatable. It all depends where one
stands on the danger-vs-reminder-annoyance spectrum. I don't have a problem with
`find-alternate-file' never querying me more than would `C-x k', but some others
might.

I have the feeling that the noble motive of protecting from data loss is perhaps
being sidetracked here. To me, this is, or should be, about what happens when
you ask to kill a given buffer - regardless of how you ask that. Whether you use
`C-x k' or `C-x C-v', the buffer to be killed (or the killing operation) should
take care of warning you and giving you a change to change your mind, whenever
that is appropriate.

That is, the _same_ warning/querying behavior is called for, regardless of how
you attempt to kill the buffer (interactively). And the behavior that is
appropriate depends on the buffer type (and possibly its modified status). The
warning/querying behavior should not depend on the particular command that calls
for the killing. And it should depend even less on the particular key binding of
that command.

That is my main point, I guess. I get the feeling that the discussion has been
approaching this problem backwards. We should back up from the supposedly
problematic key binding `C-x C-v' to the command `find-alternate-file' and
finally to the action `kill-buffer'. It's not very important _how_ you ask to
kill a buffer. What's important is that you do ask that, and what kind of buffer
you are trying to kill.

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. If `C-x k' does
warn you adequately, but `C-x C-v' does not, then that is the problem -
`find-alternate-file' should act as if `kill-buffer' were called interactively.

`find-alternate-file' does run `kill-buffer-query-functions' (but not when it
calls `kill-buffer', FWIW). I'm a bit surprised that doesn't take care of the
data-loss problem for *shell*. That var is not used in `shell.el'. I would think
that the concern for megabytes of data loss would be addressed here, where the
data is that could be lost.

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.





  reply	other threads:[~2009-07-03 22:23 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-02  1:18 C-x C-v considered harmful Bob Rogers
2009-07-02  2:39 ` Miles Bader
2009-07-02  3:10   ` Bob Rogers
2009-07-02  6:48   ` Kevin Rodgers
2009-07-02 15:17     ` Drew Adams
2009-07-03  1:09       ` Bob Rogers
2009-07-03  3:19         ` Drew Adams
2009-07-03 20:33           ` Bob Rogers
2009-07-03 22:23             ` Drew Adams [this message]
2009-07-04 23:16               ` Bob Rogers
2009-07-05  7:13                 ` Drew Adams
2009-07-06  0:39                   ` Bob Rogers
2009-07-06  1:40                     ` Drew Adams
2009-07-07 10:39                       ` Johan Bockgård
2009-07-05 10:18                 ` Richard Stallman
2009-07-05 14:56                   ` Drew Adams
2009-07-05  0:05               ` Richard Stallman
2009-07-05  7:10                 ` Drew Adams
2009-07-06 15:05                   ` Richard Stallman
2009-07-06 15:59                     ` Drew Adams
2009-07-07 10:05                       ` Richard Stallman
2009-07-06 12:04                 ` Robert J. Chassell
2009-07-06 23:49                 ` Juri Linkov
2009-07-07  1:07                   ` Drew Adams
2009-07-08  0:32                     ` Juri Linkov
2009-07-08 23:28                       ` Juri Linkov
2009-07-09 16:09                         ` Drew Adams
2009-07-09 22:10                           ` Juri Linkov
2009-07-09 22:26                             ` Drew Adams
2009-07-09 22:46                               ` Juri Linkov
2009-07-09 23:21                                 ` Drew Adams
2009-07-10  4:05                                   ` Bob Rogers
2009-07-13 20:05                         ` Juri Linkov
2009-07-16 21:57                           ` Juri Linkov
2009-07-03  2:40       ` M Jared Finder
2009-07-03  2:57         ` Miles Bader
2009-07-03 19:23         ` Richard Stallman
2009-07-03 20:07           ` Andreas Schwab
2009-07-03 20:56           ` Miles Bader
2009-07-03 13:55     ` Markus Triska
2009-07-05 22:15       ` Stefan Monnier
2009-07-05 22:42         ` Bob Rogers
2009-07-11 10:06           ` Stefan Monnier
2009-07-14  2:45             ` Bob Rogers
2009-07-14 18:34               ` Stefan Monnier
2009-07-02 21:03 ` Stefan Monnier

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=BEE2845098304E45A9351056EA6A60C7@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=rogers-emacs@rgrjr.dyndns.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.