etags.1
[bpt/emacs.git] / src / undo.c
index a498f2a..83c2327 100644 (file)
@@ -1,5 +1,5 @@
 /* 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.
 
@@ -102,7 +102,8 @@ record_delete (beg, string)
   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);
 
@@ -115,7 +116,10 @@ record_delete (beg, string)
 
       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);
@@ -137,6 +141,8 @@ record_delete (beg, string)
      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);
@@ -162,7 +168,8 @@ record_marker_adjustment (marker, adjustment)
   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);
 
@@ -196,7 +203,8 @@ record_first_change ()
   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);
 
@@ -385,8 +393,9 @@ Return what remains of the list.")
 {
   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;
@@ -403,10 +412,14 @@ Return what remains of the list.")
   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)
@@ -466,7 +479,6 @@ Return what remains of the list.")
              else if (INTEGERP (car) && INTEGERP (cdr))
                {
                  /* Element (BEG . END) means range was inserted.  */
-                 Lisp_Object end;
 
                  if (XINT (car) < BEGV
                      || XINT (cdr) > ZV)