I've lost a bunch of little bits of work here and there in the past,
and now that I lost a more substantial bit I finally sat down to find
the guilty party -- which turned out to be magit.

It's probably best to explain what I do:

  * Open some file, work on it.

  * Do a pull to get my repo updated, find that the git doesn't like
    the file with the edits there.

  * Run a git checkout on the file, re-run the pull.

  * rm the file, save the buffer that still holds my edited version.

All of that works perfectly fine, if the git work is done on a shell.
[You might argue about the habit of depending on an Emacs buffer to
hold onto some work (and I'll counter with the fact that my machine
crashes less frequently than your HD) but that's besides the point.]

What I just found is that just hittin `g' in the magit status buffer
will revert open buffers in that repo!  This is an **extremely** bad
idea, IMO.  It's kind of nice in some cases to have magit keep a
buffer updated (eg, when I undo a certain part), but just reverting
the whole thing on an operation like "refresh" on a status buffer
should *not* touch any of my buffers.  Also, looking at the code, it
seems that `magit-revert-buffers' is responsible for it, and there is
no option to turn it off.

1. This should be turned off when refreshing the status view, and
   possibly other such file-passive magit actions.  This is in
   contrast to something like `magit-reverse-item' where I *want* a
   file to change, and therefore it's often fine to assume that I want
   my buffer to go with it.

2. Still, there should be an option to turn it off completely, so that
   even such things as revert won't touch my buffers.  I personally
   would set such an option on, but I'm guessing that many people are
   fine with that.  (I have a hack that makes reverting a buffer much
   more easy and useful than the default Emacs behavior.)

3. Finally, when a buffer is reverted, it is dangerous to just use
   `revert-buffer' as is, since it also discards the undo
   information.  It is possible to save this before reverting the
   buffer, and then restore it afterwards so that the revert operation
   is itself undo-able.  (That's the hack that I referred to in the
   last point.)  But this might be an overkill, given that people
   usually expect that.  Having that option (from the previous item)
   means that I explicitly want Emacs to deal with file changes as
   usual when files change under it.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Reply via email to