use dynwind_begin and dynwind_end
[bpt/emacs.git] / src / insdel.c
index 2894af7..c6d89da 100644 (file)
@@ -701,7 +701,7 @@ count_combining_after (const unsigned char *string,
        (2) POS is the last of the current buffer.
        (3) A character at POS can't be a following byte of multibyte
            character.  */
-  if (length > 0 && ASCII_BYTE_P (string[length - 1])) /* case (1) */
+  if (length > 0 && ASCII_CHAR_P (string[length - 1])) /* case (1) */
     return 0;
   if (pos_byte == Z_BYTE)      /* case (2) */
     return 0;
@@ -1951,7 +1951,7 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
   Lisp_Object start_marker, end_marker;
   Lisp_Object preserve_marker;
   struct gcpro gcpro1, gcpro2, gcpro3;
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct rvoe_arg rvoe_arg;
 
   start = make_number (start_int);
@@ -2003,14 +2003,10 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
                                   FETCH_START, FETCH_END, Qnil);
     }
 
-  if (! NILP (start_marker))
-    free_marker (start_marker);
-  if (! NILP (end_marker))
-    free_marker (end_marker);
   RESTORE_VALUE;
   UNGCPRO;
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 /* Signal a change immediately after it happens.
@@ -2023,11 +2019,13 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
 void
 signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   struct rvoe_arg rvoe_arg;
 
-  if (inhibit_modification_hooks)
+  if (inhibit_modification_hooks) {
+    dynwind_end ();
     return;
+  }
 
   /* If we are deferring calls to the after-change functions
      and there are no before-change functions,
@@ -2048,6 +2046,7 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins)
        = Fcons (elt, combine_after_change_list);
       combine_after_change_buffer = Fcurrent_buffer ();
 
+      dynwind_end ();
       return;
     }
 
@@ -2090,7 +2089,7 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins)
     report_interval_modification (make_number (charpos),
                                  make_number (charpos + lenins));
 
-  unbind_to (count, Qnil);
+  dynwind_end ();
 }
 
 static void
@@ -2104,13 +2103,15 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
        doc: /* This function is for use internally in the function `combine-after-change-calls'.  */)
   (void)
 {
-  ptrdiff_t count = SPECPDL_INDEX ();
+  dynwind_begin ();
   ptrdiff_t beg, end, change;
   ptrdiff_t begpos, endpos;
   Lisp_Object tail;
 
-  if (NILP (combine_after_change_list))
+  if (NILP (combine_after_change_list)) {
+    dynwind_end ();
     return Qnil;
+  }
 
   /* It is rare for combine_after_change_buffer to be invalid, but
      possible.  It can happen when combine-after-change-calls is
@@ -2120,6 +2121,7 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
       || !BUFFER_LIVE_P (XBUFFER (combine_after_change_buffer)))
     {
       combine_after_change_list = Qnil;
+      dynwind_end ();
       return Qnil;
     }
 
@@ -2181,12 +2183,15 @@ DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
   signal_after_change (begpos, endpos - begpos - change, endpos - begpos);
   update_compositions (begpos, endpos, CHECK_ALL);
 
-  return unbind_to (count, Qnil);
+  dynwind_end ();
+  return Qnil;
 }
 \f
 void
 syms_of_insdel (void)
 {
+#include "insdel.x"
+
   staticpro (&combine_after_change_list);
   staticpro (&combine_after_change_buffer);
   combine_after_change_list = Qnil;
@@ -2204,6 +2209,4 @@ as well as hooks attached to text properties and overlays.  */);
   DEFSYM (Qinhibit_modification_hooks, "inhibit-modification-hooks");
 
   DEFSYM (Qregion_extract_function, "region-extract-function");
-
-  defsubr (&Scombine_after_change_execute);
 }