]> code.delx.au - gnu-emacs/blobdiff - src/undo.c
(BITS_PER_CHAR, BITS_PER_INT, BITS_PER_SHORT)
[gnu-emacs] / src / undo.c
index 9fdba2f1d8f505a4983cef264cb774b20718995e..efa19107419cf805ca57aca96a1ee76dd37b238e 100644 (file)
@@ -42,7 +42,7 @@ Lisp_Object pending_boundary;
    because we don't need to record the contents.)  */
 
 record_insert (beg, length)
-     Lisp_Object beg, length;
+     int beg, length;
 {
   Lisp_Object lbeg, lend;
 
@@ -57,7 +57,7 @@ record_insert (beg, length)
     Fundo_boundary ();
   XSETBUFFER (last_undo_buffer, current_buffer);
 
-  if (MODIFF <= current_buffer->save_modified)
+  if (MODIFF <= SAVE_MODIFF)
     record_first_change ();
 
   /* If this is following another insertion and consecutive with it
@@ -69,15 +69,15 @@ record_insert (beg, length)
       if (CONSP (elt)
          && INTEGERP (XCONS (elt)->car)
          && INTEGERP (XCONS (elt)->cdr)
-         && XINT (XCONS (elt)->cdr) == XINT (beg))
+         && XINT (XCONS (elt)->cdr) == beg)
        {
-         XSETINT (XCONS (elt)->cdr, XINT (beg) + XINT (length));
+         XSETINT (XCONS (elt)->cdr, beg + length);
          return;
        }
     }
 
-  lbeg = beg;
-  XSETINT (lend, XINT (beg) + XINT (length));
+  XSETFASTINT (lbeg, beg);
+  XSETINT (lend, beg + length);
   current_buffer->undo_list = Fcons (Fcons (lbeg, lend),
                                      current_buffer->undo_list);
 }
@@ -105,7 +105,7 @@ record_delete (beg, length)
   at_boundary = (CONSP (current_buffer->undo_list)
                 && NILP (XCONS (current_buffer->undo_list)->car));
 
-  if (MODIFF <= current_buffer->save_modified)
+  if (MODIFF <= SAVE_MODIFF)
     record_first_change ();
 
   if (point == beg + length)
@@ -146,6 +146,7 @@ record_change (beg, length)
 record_first_change ()
 {
   Lisp_Object high, low;
+  struct buffer *base_buffer = current_buffer;
 
   if (EQ (current_buffer->undo_list, Qt))
     return;
@@ -154,8 +155,11 @@ record_first_change ()
     Fundo_boundary ();
   XSETBUFFER (last_undo_buffer, current_buffer);
 
-  XSETFASTINT (high, (current_buffer->modtime >> 16) & 0xffff);
-  XSETFASTINT (low, current_buffer->modtime & 0xffff);
+  if (base_buffer->base_buffer)
+    base_buffer = base_buffer->base_buffer;
+
+  XSETFASTINT (high, (base_buffer->modtime >> 16) & 0xffff);
+  XSETFASTINT (low, base_buffer->modtime & 0xffff);
   current_buffer->undo_list = Fcons (Fcons (Qt, Fcons (high, low)), current_buffer->undo_list);
 }
 
@@ -187,7 +191,7 @@ record_property_change (beg, length, prop, value, buffer)
   if (boundary)
     Fundo_boundary ();
 
-  if (MODIFF <= current_buffer->save_modified)
+  if (MODIFF <= SAVE_MODIFF)
     record_first_change ();
 
   XSETINT (lbeg, beg);
@@ -380,15 +384,20 @@ Return what remains of the list.")
                  /* Element (t high . low) records previous modtime.  */
                  Lisp_Object high, low;
                  int mod_time;
+                 struct buffer *base_buffer = current_buffer;
 
                  high = Fcar (cdr);
                  low = Fcdr (cdr);
                  mod_time = (XFASTINT (high) << 16) + XFASTINT (low);
+
+                 if (current_buffer->base_buffer)
+                   base_buffer = current_buffer->base_buffer;
+
                  /* If this records an obsolete save
                     (not matching the actual disk file)
                     then don't mark unmodified.  */
-                 if (mod_time != current_buffer->modtime)
-                   break;
+                 if (mod_time != base_buffer->modtime)
+                   continue;
 #ifdef CLASH_DETECTION
                  Funlock_buffer ();
 #endif /* CLASH_DETECTION */