/* undo handling for GNU Emacs.
- Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1993, 1994, 2000 Free Software Foundation, Inc.
This file is part of GNU Emacs.
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);
while (1)
{
- elt = XCAR (tail);
+ if (NILP (tail))
+ elt = Qnil;
+ else
+ elt = XCAR (tail);
if (NILP (elt) || ! (CONSP (elt) && MARKERP (XCAR (elt))))
break;
tail = XCDR (tail);
point wasn't at start of deleted range, record where it was. */
if (at_boundary
&& last_point_position != XFASTINT (sbeg)
+ /* If we're called from batch mode, this could be nil. */
+ && BUFFERP (last_point_position_buffer)
&& current_buffer == XBUFFER (last_point_position_buffer))
current_buffer->undo_list
= Fcons (make_number (last_point_position), current_buffer->undo_list);
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 (EQ (current_buffer->undo_list, Qt))
return;
- 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);
{
struct gcpro gcpro1, gcpro2;
Lisp_Object next;
- int count = specpdl_ptr - specpdl;
+ int count = BINDING_STACK_SIZE ();
register int arg;
+
#if 0 /* This is a good feature, but would make undo-start
unable to do what is expected. */
Lisp_Object tem;
next = Qnil;
GCPRO2 (next, list);
- /* Don't let read-only properties interfere with undo. */
+ /* In a writable buffer, enable undoing read-only text that is so
+ because of text properties. */
if (NILP (current_buffer->read_only))
specbind (Qinhibit_read_only, Qt);
+ /* Don't let `intangible' properties interfere with undo. */
+ specbind (Qinhibit_point_motion_hooks, Qt);
+
while (arg > 0)
{
while (1)
else if (INTEGERP (car) && INTEGERP (cdr))
{
/* Element (BEG . END) means range was inserted. */
- Lisp_Object end;
if (XINT (car) < BEGV
|| XINT (cdr) > ZV)