help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: What's your favourite *under_publicized* editing feature ofEmacs?


From: Jason Earl
Subject: Re: What's your favourite *under_publicized* editing feature ofEmacs?
Date: Wed, 23 Feb 2011 12:22:58 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

On Wed, Feb 23 2011, Cthun wrote:

> On 23/02/2011 12:22 AM, Tim X wrote:
>> Cthun<address@hidden>  writes:
>>
>>> On 22/02/2011 2:47 PM, Alan Mackenzie wrote:
>>>> There seems to be a contradiction between those last two
>>>> paragraphs.  Saving buffers and finding files are relatively rare
>>>> operations which thus shouldn't be given very easy to press key
>>>> sequences like C-s and C-o.
>>>
>>> Where do you live where software never crashes and the electricity
>>> never goes out? Most of us learn to save very frequently to limit
>>> how much we'll have to do over again if the power goes out or
>>> whatever.
>>
>> Most of us use smart editors that auto-save regularly and free the
>> user form having to do this manually all the time.
>
> Ah, auto-save, another fruitful source of trouble.

I don't think that I have ever had problems with auto save.  Especially
with the sort of plain text documents that Emacs deals with.

> Auto-save has two design alternatives. One, it just acts like the user
> hit control-S, every some interval.

This is what I set up.  In fact, I have an entire directory (under
~/.emacs.d/backup) full of old save files.  I don't think that I have
ever actually fished a file out of there, Emacs' recover-session stuff
has always been more than good enough, but it is nice to know that they
exist.

> This runs into trouble if you do something drastic you later want to
> undo.

Actually, Emacs warns you before it makes drastic changes to an autosave
file.  This at least gives you the opportunity to do something about it.

> Sure you can fork the file, but if you forget ... and then there's
> forking it "dangerously" -- first you make a big deletion, and then
> you hit alt, f, a for save-as to save the drastically-changed version
> under a new name, but pow, an autosave happens to occur *after* the
> deletion and *before* the save-as. So much for being able to undo
> it...

The solution, of course, is to manually save *before* the fork.  I real
life I don't think that this is much of a problem, especially with Emacs
which has infinite undo and which tends to be a very stable piece of
software.

What's more, Emacs is flexible enough that you can easily set up
whatever sort of auto-save functionality that you think you want.  If
you feel like your data is so critical that you want it saved in a
version control system and pushed off to a new machine every 5 minutes
Emacs can do that.  It has an auto-save-hook that you can add code to,
and it has all sorts of built in machinery for committing to version
control, saving files on remote machines, etc.

> The other option is auto-save to some temporary file, or a sequence of
> numbered files. Of course if you have a power outage or something now
> you have to go hunting for where the darn thing saved
> these. Depending, they may even be vulnerable to being erased by an
> automatic temp file cleanup script before you get to them.

Emacs does not (by default) save auto-save files somewhere where they
are likely to get cleaned up.  I suppose you could set up your system in
such a way as to jeopardize these files, but you can not hardly blame
Emacs for that.

Another alternative, of course, is to simply save the file whenever you
feel you have something worth saving.  C-x C-s is not exactly hard to
type.  C-x v v would probably even commit the changes to version
control.

> Sequences of numbered files used to risk filling up the filesystem,
> too, but not with text files in this day and age.

On the bright side Emacs can be made to do whatever makes you the
happiest.  Very few other programs have anywhere near that sort of
flexibility.  For most folks, however, the defaults are what they want.
I don't like having the auto-save files clutter up my directories, so I
customized a single variable to save them in a central location.  That
seems easy enough to me.

Jason


reply via email to

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