emacs-devel
[Top][All Lists]
Advanced

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

[rant] Should reverting a buffer really discard undo history?


From: Daniel Brockman
Subject: [rant] Should reverting a buffer really discard undo history?
Date: Mon, 30 May 2005 21:57:21 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Steps to reproduce:

  1.  C-x C-f foo RET original contents C-x C-s

  2.  M-! echo new contents > foo RET

  3.  Try to change the buffer.

  4.  Answer `r' to the question about really editing the buffer.

  5.  Note that at this point you cannot retrieve the original buffer
      contents by undoing.

I managed to lose my ~/.emacs last night.  It was all my fault, and
I'm still trying to forgive myself for not keeping a recent backup.

Luckily, I use Customize to tweak everything that uses `defcustom',
so I was able to reproduce a lot from my running Emacs instance.
Unfortunately, you cannot use Customize to, e.g., bind keys.
(Has implementing this ever been considered, by the way?)

Please skip the following three paragraphs unless you are interested
in the details of how the accident happened.

<long-version>
I was using a broken FTP program to upload some files to my machine
(of course, I did not at the time know that the program was broken),
and without my noticing it, the FTP program uploaded the two files
`.emacs' and `.emacs~', overwriting the ones in my home directory.

A few hours later, I'm tweaking something in a Customize buffer and
hit the button ``Save for future sessions''.  Emacs tells me that the
file `.emacs' changed on disk, and asks me if I want to revert it.
Here's where I make my fatal mistake --- I say `yes'.

Yes, I did understand the question, and I did know that reverting a
buffer is a potentially dangerous opreation.  (If it weren't, Emacs
probably wouldn't even ask me about it.)  But, I reasoned, if the file
had changed on disk, that must be because *I* had changed it somehow.
I did not consider the possibility that a broken FTP program might
have replaced the file and its backup with what amounts to garbage.
</long-version>

Now this is a pretty unlikely scenario.  But all it really takes for
the equivalent to happen is that you mess up some file that you have
in an Emacs buffer, and then revert that Emacs buffer.

My ~/.emacs would have been saved had Emacs kept the buffer contents
in undo history when reverting the file.  I'd like to if there is any
way to enable this, and (if so) why Emacs does not do it by default.

By the way, the first thing I did following this incident was to set
`version-control' to t, and curse myself for not doing so earlier.

-- 
Daniel Brockman <address@hidden>





reply via email to

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