(record_insert, record_delete, record_first_change, record_property_change):
[bpt/emacs.git] / src / undo.c
index fef2698..be6d506 100644 (file)
@@ -55,20 +55,20 @@ record_insert (beg, length)
 
   if (current_buffer != XBUFFER (last_undo_buffer))
     Fundo_boundary ();
-  XSET (last_undo_buffer, Lisp_Buffer, current_buffer);
+  XSETBUFFER (last_undo_buffer, current_buffer);
 
   if (MODIFF <= current_buffer->save_modified)
     record_first_change ();
 
   /* If this is following another insertion and consecutive with it
      in the buffer, combine the two.  */
-  if (XTYPE (current_buffer->undo_list) == Lisp_Cons)
+  if (CONSP (current_buffer->undo_list))
     {
       Lisp_Object elt;
       elt = XCONS (current_buffer->undo_list)->car;
-      if (XTYPE (elt) == Lisp_Cons
-         && XTYPE (XCONS (elt)->car) == Lisp_Int
-         && XTYPE (XCONS (elt)->cdr) == Lisp_Int
+      if (CONSP (elt)
+         && INTEGERP (XCONS (elt)->car)
+         && INTEGERP (XCONS (elt)->cdr)
          && XINT (XCONS (elt)->cdr) == XINT (beg))
        {
          XSETINT (XCONS (elt)->cdr, XINT (beg) + XINT (length));
@@ -77,7 +77,7 @@ record_insert (beg, length)
     }
 
   lbeg = beg;
-  XSET (lend, Lisp_Int, XINT (beg) + XINT (length));
+  XSETINT (lend, XINT (beg) + XINT (length));
   current_buffer->undo_list = Fcons (Fcons (lbeg, lend),
                                      current_buffer->undo_list);
 }
@@ -100,7 +100,7 @@ record_delete (beg, length)
 
   if (current_buffer != XBUFFER (last_undo_buffer))
     Fundo_boundary ();
-  XSET (last_undo_buffer, Lisp_Buffer, current_buffer);
+  XSETBUFFER (last_undo_buffer, current_buffer);
 
   at_boundary = (CONSP (current_buffer->undo_list)
                 && NILP (XCONS (current_buffer->undo_list)->car));
@@ -109,7 +109,7 @@ record_delete (beg, length)
     record_first_change ();
 
   if (point == beg + length)
-    XSET (sbeg, Lisp_Int, -beg);
+    XSETINT (sbeg, -beg);
   else
     XFASTINT (sbeg) = beg;
   XFASTINT (lbeg) = beg;
@@ -152,7 +152,7 @@ record_first_change ()
 
   if (current_buffer != XBUFFER (last_undo_buffer))
     Fundo_boundary ();
-  XSET (last_undo_buffer, Lisp_Buffer, current_buffer);
+  XSETBUFFER (last_undo_buffer, current_buffer);
 
   XFASTINT (high) = (current_buffer->modtime >> 16) & 0xffff;
   XFASTINT (low) = current_buffer->modtime & 0xffff;
@@ -190,8 +190,8 @@ record_property_change (beg, length, prop, value, buffer)
   if (MODIFF <= current_buffer->save_modified)
     record_first_change ();
 
-  XSET (lbeg, Lisp_Int, beg);
-  XSET (lend, Lisp_Int, beg + length);
+  XSETINT (lbeg, beg);
+  XSETINT (lend, beg + length);
   entry = Fcons (Qnil, Fcons (prop, Fcons (value, Fcons (lbeg, lend))));
   current_buffer->undo_list = Fcons (entry, current_buffer->undo_list);
 
@@ -249,8 +249,7 @@ truncate_undo_list (list, minsize, maxsize)
      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 (XTYPE (next) == Lisp_Cons
-      && NILP (XCONS (next)->car))
+  if (CONSP (next) && NILP (XCONS (next)->car))
     {
       /* Add in the space occupied by this element and its chain link.  */
       size_so_far += sizeof (struct Lisp_Cons);
@@ -259,18 +258,17 @@ truncate_undo_list (list, minsize, maxsize)
       prev = next;
       next = XCONS (next)->cdr;
     }
-  while (XTYPE (next) == Lisp_Cons
-        && ! NILP (XCONS (next)->car))
+  while (CONSP (next) && ! NILP (XCONS (next)->car))
     {
       Lisp_Object elt;
       elt = XCONS (next)->car;
 
       /* Add in the space occupied by this element and its chain link.  */
       size_so_far += sizeof (struct Lisp_Cons);
-      if (XTYPE (elt) == Lisp_Cons)
+      if (CONSP (elt))
        {
          size_so_far += sizeof (struct Lisp_Cons);
-         if (XTYPE (XCONS (elt)->car) == Lisp_String)
+         if (STRINGP (XCONS (elt)->car))
            size_so_far += (sizeof (struct Lisp_String) - 1
                            + XSTRING (XCONS (elt)->car)->size);
        }
@@ -279,10 +277,10 @@ truncate_undo_list (list, minsize, maxsize)
       prev = next;
       next = XCONS (next)->cdr;
     }
-  if (XTYPE (next) == Lisp_Cons)
+  if (CONSP (next))
     last_boundary = prev;
 
-  while (XTYPE (next) == Lisp_Cons)
+  while (CONSP (next))
     {
       Lisp_Object elt;
       elt = XCONS (next)->car;
@@ -302,10 +300,10 @@ truncate_undo_list (list, minsize, maxsize)
 
       /* Add in the space occupied by this element and its chain link.  */
       size_so_far += sizeof (struct Lisp_Cons);
-      if (XTYPE (elt) == Lisp_Cons)
+      if (CONSP (elt))
        {
          size_so_far += sizeof (struct Lisp_Cons);
-         if (XTYPE (XCONS (elt)->car) == Lisp_String)
+         if (STRINGP (XCONS (elt)->car))
            size_so_far += (sizeof (struct Lisp_String) - 1
                            + XSTRING (XCONS (elt)->car)->size);
        }
@@ -369,9 +367,9 @@ Return what remains of the list.")
          if (NILP (next))
            break;
          /* Handle an integer by setting point to that value.  */
-         if (XTYPE (next) == Lisp_Int)
+         if (INTEGERP (next))
            SET_PT (clip_to_bounds (BEGV, XINT (next), ZV));
-         else if (XTYPE (next) == Lisp_Cons)
+         else if (CONSP (next))
            {
              Lisp_Object car, cdr;
 
@@ -412,7 +410,7 @@ Return what remains of the list.")
                  Fput_text_property (beg, end, prop, val, Qnil);
                }
 #endif /* USE_TEXT_PROPERTIES */
-             else if (XTYPE (car) == Lisp_Int && XTYPE (cdr) == Lisp_Int)
+             else if (INTEGERP (car) && INTEGERP (cdr))
                {
                  /* Element (BEG . END) means range was inserted.  */
                  Lisp_Object end;
@@ -425,7 +423,7 @@ Return what remains of the list.")
                  Fgoto_char (car);
                  Fdelete_region (car, cdr);
                }
-             else if (XTYPE (car) == Lisp_String && XTYPE (cdr) == Lisp_Int)
+             else if (STRINGP (car) && INTEGERP (cdr))
                {
                  /* Element (STRING . POS) means STRING was deleted.  */
                  Lisp_Object membuf;