Commit c58632fc authored by Richard M. Stallman's avatar Richard M. Stallman

(syms_of_undo): staticpro pending_boundary.

(pending_boundary): New variable.
(syms_of_undo): Initialize it.
(Fundo_boundary): Use pending_boundary.
(record_insert, record_delete, record_property_change):
Set pending_boundary.
parent 5d694741
......@@ -29,6 +29,13 @@ Lisp_Object last_undo_buffer;
Lisp_Object Qinhibit_read_only;
/* The first time a command records something for undo.
it also allocates the undo-boundary object
which will be added to the list at the end of the command.
This ensures we can't run out of space while trying to make
an undo-boundary. */
Lisp_Object pending_boundary;
/* Record an insertion that just happened or is about to happen,
for LENGTH characters at position BEG.
(It is possible to record an insertion before or after the fact
......@@ -42,6 +49,10 @@ record_insert (beg, length)
if (EQ (current_buffer->undo_list, Qt))
return;
/* Allocate a cons cell to be the undo boundary after this command. */
if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil);
if (current_buffer != XBUFFER (last_undo_buffer))
Fundo_boundary ();
XSET (last_undo_buffer, Lisp_Buffer, current_buffer);
......@@ -82,6 +93,10 @@ record_delete (beg, length)
if (EQ (current_buffer->undo_list, Qt))
return;
/* Allocate a cons cell to be the undo boundary after this command. */
if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil);
if (current_buffer != XBUFFER (last_undo_buffer))
Fundo_boundary ();
XSET (last_undo_buffer, Lisp_Buffer, current_buffer);
......@@ -151,6 +166,10 @@ record_property_change (beg, length, prop, value, buffer)
if (EQ (XBUFFER (buffer)->undo_list, Qt))
return;
/* Allocate a cons cell to be the undo boundary after this command. */
if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil);
if (!EQ (buffer, last_undo_buffer))
boundary = 1;
last_undo_buffer = buffer;
......@@ -183,7 +202,19 @@ but another undo command will undo to the previous boundary.")
return Qnil;
tem = Fcar (current_buffer->undo_list);
if (!NILP (tem))
current_buffer->undo_list = Fcons (Qnil, current_buffer->undo_list);
{
/* One way or another, cons nil onto the front of the undo list. */
if (!NILP (pending_boundary))
{
/* If we have preallocated the cons cell to use here,
use that one. */
XCONS (pending_boundary)->cdr = current_buffer->undo_list;
current_buffer->undo_list = pending_boundary;
pending_boundary = Qnil;
}
else
current_buffer->undo_list = Fcons (Qnil, current_buffer->undo_list);
}
return Qnil;
}
......@@ -425,6 +456,9 @@ syms_of_undo ()
Qinhibit_read_only = intern ("inhibit-read-only");
staticpro (&Qinhibit_read_only);
pending_boundary = Qnil;
staticpro (&pending_boundary);
defsubr (&Sprimitive_undo);
defsubr (&Sundo_boundary);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment