Fix some uses of int instead of EMACS_INT.
[bpt/emacs.git] / src / insdel.c
index 1085d64..fb26fe7 100644 (file)
@@ -74,6 +74,8 @@ Lisp_Object combine_after_change_buffer;
 
 Lisp_Object Qinhibit_modification_hooks;
 
+extern Lisp_Object Vselect_active_regions, Vsaved_region_selection, Qonly;
+
 \f
 /* Check all markers in the current buffer, looking for something invalid.  */
 
@@ -1628,7 +1630,7 @@ replace_range (EMACS_INT from, EMACS_INT to, Lisp_Object new,
 void
 replace_range_2 (EMACS_INT from, EMACS_INT from_byte,
                 EMACS_INT to, EMACS_INT to_byte,
-                char *ins, EMACS_INT inschars, EMACS_INT insbytes,
+                const char *ins, EMACS_INT inschars, EMACS_INT insbytes,
                 int markers)
 {
   EMACS_INT nbytes_del, nchars_del;
@@ -2047,6 +2049,22 @@ prepare_to_modify_buffer (EMACS_INT start, EMACS_INT end,
           base_buffer->filename);
 #endif /* not CLASH_DETECTION */
 
+  /* If `select-active-regions' is non-nil, save the region text.  */
+  if (!NILP (current_buffer->mark_active)
+      && NILP (Vsaved_region_selection)
+      && (EQ (Vselect_active_regions, Qonly)
+         ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
+         : (!NILP (Vselect_active_regions)
+            && !NILP (Vtransient_mark_mode))))
+    {
+      EMACS_INT b = XINT (Fmarker_position (current_buffer->mark));
+      EMACS_INT e = PT;
+      if (b < e)
+       Vsaved_region_selection = make_buffer_string (b, e, 0);
+      else if (b > e)
+       Vsaved_region_selection = make_buffer_string (e, b, 0);
+    }
+
   signal_before_change (start, end, preserve_ptr);
 
   if (current_buffer->newline_cache)
@@ -2267,7 +2285,7 @@ Fcombine_after_change_execute_1 (Lisp_Object val)
 DEFUN ("combine-after-change-execute", Fcombine_after_change_execute,
        Scombine_after_change_execute, 0, 0, 0,
        doc: /* This function is for use internally in `combine-after-change-calls'.  */)
-     ()
+  (void)
 {
   int count = SPECPDL_INDEX ();
   EMACS_INT beg, end, change;