if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil);
- if (current_buffer != XBUFFER (last_undo_buffer))
+ if (!BUFFERP (last_undo_buffer)
+ || current_buffer != XBUFFER (last_undo_buffer))
Fundo_boundary ();
XSETBUFFER (last_undo_buffer, current_buffer);
if (CONSP (current_buffer->undo_list))
{
Lisp_Object elt;
- elt = XCONS (current_buffer->undo_list)->car;
+ elt = XCAR (current_buffer->undo_list);
if (CONSP (elt)
- && INTEGERP (XCONS (elt)->car)
- && INTEGERP (XCONS (elt)->cdr)
- && XINT (XCONS (elt)->cdr) == beg)
+ && INTEGERP (XCAR (elt))
+ && INTEGERP (XCDR (elt))
+ && XINT (XCDR (elt)) == beg)
{
- XSETINT (XCONS (elt)->cdr, beg + length);
+ XSETINT (XCDR (elt), beg + length);
return;
}
}
}
/* Record that a deletion is about to take place,
- for LENGTH characters at location BEG. */
+ of the characters in STRING, at location BEG. */
void
-record_delete (beg, length)
- int beg, length;
+record_delete (beg, string)
+ int beg;
+ Lisp_Object string;
{
- Lisp_Object lbeg, lend, sbeg;
+ Lisp_Object sbeg;
int at_boundary;
if (EQ (current_buffer->undo_list, Qt))
Fundo_boundary ();
XSETBUFFER (last_undo_buffer, current_buffer);
- at_boundary = (CONSP (current_buffer->undo_list)
- && NILP (XCONS (current_buffer->undo_list)->car));
+ if (CONSP (current_buffer->undo_list))
+ {
+ /* Set AT_BOUNDARY to 1 only when we have nothing other than
+ marker adjustment before undo boundary. */
+
+ Lisp_Object tail = current_buffer->undo_list, elt;
+
+ while (1)
+ {
+ if (NILP (tail))
+ elt = Qnil;
+ else
+ elt = XCAR (tail);
+ if (NILP (elt) || ! (CONSP (elt) && MARKERP (XCAR (elt))))
+ break;
+ tail = XCDR (tail);
+ }
+ at_boundary = NILP (elt);
+ }
+ else
+ at_boundary = 0;
if (MODIFF <= SAVE_MODIFF)
record_first_change ();
- if (PT == beg + length)
+ if (PT == beg + XSTRING (string)->size)
XSETINT (sbeg, -beg);
else
XSETFASTINT (sbeg, beg);
- XSETFASTINT (lbeg, beg);
- XSETFASTINT (lend, beg + length);
/* If we are just after an undo boundary, and
point wasn't at start of deleted range, record where it was. */
= Fcons (make_number (last_point_position), current_buffer->undo_list);
current_buffer->undo_list
- = Fcons (Fcons (Fbuffer_substring (lbeg, lend), sbeg),
- current_buffer->undo_list);
+ = Fcons (Fcons (string, sbeg), current_buffer->undo_list);
}
/* Record the fact that MARKER is about to be adjusted by ADJUSTMENT.
/* Record that a replacement is about to take place,
for LENGTH characters at location BEG.
- The replacement does not change the number of characters. */
+ The replacement must not change the number of characters. */
void
record_change (beg, length)
int beg, length;
{
- record_delete (beg, length);
+ record_delete (beg, make_buffer_string (beg, beg + length, 1));
record_insert (beg, length);
}
\f
{
/* If we have preallocated the cons cell to use here,
use that one. */
- XCONS (pending_boundary)->cdr = current_buffer->undo_list;
+ XCDR (pending_boundary) = current_buffer->undo_list;
current_buffer->undo_list = pending_boundary;
pending_boundary = Qnil;
}
Skip, skip, skip the undo, skip, skip, skip the undo,
Skip, skip, skip the undo, skip to the undo bound'ry.
(Get it? "Skip to my Loo?") */
- if (CONSP (next) && NILP (XCONS (next)->car))
+ if (CONSP (next) && NILP (XCAR (next)))
{
/* Add in the space occupied by this element and its chain link. */
size_so_far += sizeof (struct Lisp_Cons);
/* Advance to next element. */
prev = next;
- next = XCONS (next)->cdr;
+ next = XCDR (next);
}
- while (CONSP (next) && ! NILP (XCONS (next)->car))
+ while (CONSP (next) && ! NILP (XCAR (next)))
{
Lisp_Object elt;
- elt = XCONS (next)->car;
+ elt = XCAR (next);
/* Add in the space occupied by this element and its chain link. */
size_so_far += sizeof (struct Lisp_Cons);
if (CONSP (elt))
{
size_so_far += sizeof (struct Lisp_Cons);
- if (STRINGP (XCONS (elt)->car))
+ if (STRINGP (XCAR (elt)))
size_so_far += (sizeof (struct Lisp_String) - 1
- + XSTRING (XCONS (elt)->car)->size);
+ + XSTRING (XCAR (elt))->size);
}
/* Advance to next element. */
prev = next;
- next = XCONS (next)->cdr;
+ next = XCDR (next);
}
if (CONSP (next))
last_boundary = prev;
while (CONSP (next))
{
Lisp_Object elt;
- elt = XCONS (next)->car;
+ elt = XCAR (next);
/* When we get to a boundary, decide whether to truncate
either before or after it. The lower threshold, MINSIZE,
if (CONSP (elt))
{
size_so_far += sizeof (struct Lisp_Cons);
- if (STRINGP (XCONS (elt)->car))
+ if (STRINGP (XCAR (elt)))
size_so_far += (sizeof (struct Lisp_String) - 1
- + XSTRING (XCONS (elt)->car)->size);
+ + XSTRING (XCAR (elt))->size);
}
/* Advance to next element. */
prev = next;
- next = XCONS (next)->cdr;
+ next = XCDR (next);
}
/* If we scanned the whole list, it is short enough; don't change it. */
/* Truncate at the boundary where we decided to truncate. */
if (!NILP (last_boundary))
{
- XCONS (last_boundary)->cdr = Qnil;
+ XCDR (last_boundary) = Qnil;
return list;
}
else
#endif /* CLASH_DETECTION */
Fset_buffer_modified_p (Qnil);
}
-#ifdef USE_TEXT_PROPERTIES
else if (EQ (car, Qnil))
{
/* Element (nil prop val beg . end) is property change. */
Fput_text_property (beg, end, prop, val, Qnil);
}
-#endif /* USE_TEXT_PROPERTIES */
else if (INTEGERP (car) && INTEGERP (cdr))
{
/* Element (BEG . END) means range was inserted. */
return unbind_to (count, list);
}
+void
syms_of_undo ()
{
Qinhibit_read_only = intern ("inhibit-read-only");