[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

32.10 Maintaining Undo Lists

This section describes how to enable and disable undo information for a given buffer. It also explains how the undo list is truncated automatically so it doesn't get too big.

Recording of undo information in a newly created buffer is normally enabled to start with; but if the buffer name starts with a space, the undo recording is initially disabled. You can explicitly enable or disable undo recording with the following two functions, or by setting buffer-undo-list yourself.

Command: buffer-enable-undo &optional buffer-or-name
This command enables recording undo information for buffer buffer-or-name, so that subsequent changes can be undone. If no argument is supplied, then the current buffer is used. This function does nothing if undo recording is already enabled in the buffer. It returns nil.

In an interactive call, buffer-or-name is the current buffer. You cannot specify any other buffer.

Command: buffer-disable-undo &optional buffer
Command: buffer-flush-undo &optional buffer
This function discards the undo list of buffer, and disables further recording of undo information. As a result, it is no longer possible to undo either previous changes or any subsequent changes. If the undo list of buffer is already disabled, this function has no effect.

This function returns nil.

The name buffer-flush-undo is not considered obsolete, but the preferred name is buffer-disable-undo.

As editing continues, undo lists get longer and longer. To prevent them from using up all available memory space, garbage collection trims them back to size limits you can set. (For this purpose, the "size" of an undo list measures the cons cells that make up the list, plus the strings of deleted text.) Two variables control the range of acceptable sizes: undo-limit and undo-strong-limit.

Variable: undo-limit
This is the soft limit for the acceptable size of an undo list. The change group at which this size is exceeded is the last one kept.

Variable: undo-strong-limit
This is the upper limit for the acceptable size of an undo list. The change group at which this size is exceeded is discarded itself (along with all older change groups). There is one exception: the very latest change group is never discarded no matter how big it is.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on May 2, 2002 using texi2html