unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [rant] Should reverting a buffer really discard undo history?
@ 2005-05-30 19:57 Daniel Brockman
  2005-05-30 21:28 ` Stefan Monnier
  2005-05-31 17:47 ` Richard Stallman
  0 siblings, 2 replies; 13+ messages in thread
From: Daniel Brockman @ 2005-05-30 19:57 UTC (permalink / raw)


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 <daniel@brockman.se>

^ permalink raw reply	[flat|nested] 13+ messages in thread
[parent not found: <E1DcrBs-0005I0-W6@monty-python.gnu.org>]

end of thread, other threads:[~2005-06-03 22:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-30 19:57 [rant] Should reverting a buffer really discard undo history? Daniel Brockman
2005-05-30 21:28 ` Stefan Monnier
2005-05-30 21:56   ` Juanma Barranquero
2005-05-30 21:58   ` Lennart Borgman
2005-06-01 23:19   ` Dan Nicolaescu
2005-06-01 23:31     ` Stefan Monnier
2005-06-02 18:10       ` Dan Nicolaescu
2005-06-03 22:30         ` Richard Stallman
2005-05-31 17:47 ` Richard Stallman
2005-05-31 18:23   ` Drew Adams
2005-06-01 17:25     ` Richard Stallman
     [not found] <E1DcrBs-0005I0-W6@monty-python.gnu.org>
2005-05-31  0:28 ` Jonathan Yavner
2005-05-31  2:30   ` Daniel Brockman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).