]> code.delx.au - gnu-emacs/blobdiff - src/insdel.c
Fix ob-lisp.el expectation that slime would be available
[gnu-emacs] / src / insdel.c
index 2024cfc362f224087e14e82ff52c453766a0769c..ff380ada1928eb96011b36cd08884d8f832cdd9f 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.  */
 
@@ -164,28 +166,9 @@ gap_left (EMACS_INT charpos, EMACS_INT bytepos, int newgap)
       /* Move at most 32000 chars before checking again for a quit.  */
       if (i > 32000)
        i = 32000;
-#ifdef GAP_USE_BCOPY
-      if (i >= 128
-         /* bcopy is safe if the two areas of memory do not overlap
-            or on systems where bcopy is always safe for moving upward.  */
-         && (BCOPY_UPWARD_SAFE
-             || to - from >= 128))
-       {
-         /* If overlap is not safe, avoid it by not moving too many
-            characters at once.  */
-         if (!BCOPY_UPWARD_SAFE && i > to - from)
-           i = to - from;
-         new_s1 -= i;
-         from -= i, to -= i;
-         bcopy (from, to, i);
-       }
-      else
-#endif
-       {
-         new_s1 -= i;
-         while (--i >= 0)
-           *--to = *--from;
-       }
+      new_s1 -= i;
+      from -= i, to -= i;
+      memmove (to, from, i);
     }
 
   /* Adjust markers, and buffer data structure, to put the gap at BYTEPOS.
@@ -238,28 +221,9 @@ gap_right (EMACS_INT charpos, EMACS_INT bytepos)
       /* Move at most 32000 chars before checking again for a quit.  */
       if (i > 32000)
        i = 32000;
-#ifdef GAP_USE_BCOPY
-      if (i >= 128
-         /* bcopy is safe if the two areas of memory do not overlap
-            or on systems where bcopy is always safe for moving downward.  */
-         && (BCOPY_DOWNWARD_SAFE
-             || from - to >= 128))
-       {
-         /* If overlap is not safe, avoid it by not moving too many
-            characters at once.  */
-         if (!BCOPY_DOWNWARD_SAFE && i > from - to)
-           i = from - to;
-         new_s1 += i;
-         bcopy (from, to, i);
-         from += i, to += i;
-       }
-      else
-#endif
-       {
-         new_s1 += i;
-         while (--i >= 0)
-           *to++ = *from++;
-       }
+      new_s1 += i;
+      memmove (to, from, i);
+      from += i, to += i;
     }
 
   adjust_markers_gap_motion (GPT_BYTE + GAP_SIZE, bytepos + GAP_SIZE,
@@ -585,7 +549,7 @@ make_gap_smaller (EMACS_INT nbytes_removed)
   /* Pretend that the last unwanted part of the gap is the entire gap,
      and that the first desired part of the gap is part of the buffer
      text.  */
-  bzero (GPT_ADDR, new_gap_size);
+  memset (GPT_ADDR, 0, new_gap_size);
   GPT += new_gap_size;
   GPT_BYTE += new_gap_size;
   Z += new_gap_size;
@@ -636,7 +600,7 @@ copy_text (const unsigned char *from_addr, unsigned char *to_addr,
 {
   if (from_multibyte == to_multibyte)
     {
-      bcopy (from_addr, to_addr, nbytes);
+      memcpy (to_addr, from_addr, nbytes);
       return nbytes;
     }
   else if (from_multibyte)
@@ -966,7 +930,7 @@ insert_1_both (const unsigned char *string,
   MODIFF++;
   CHARS_MODIFF = MODIFF;
 
-  bcopy (string, GPT_ADDR, nbytes);
+  memcpy (GPT_ADDR, string, nbytes);
 
   GAP_SIZE -= nbytes;
   GPT += nchars;
@@ -1007,7 +971,7 @@ insert_1_both (const unsigned char *string,
    copy them into the buffer.
 
    It does not work to use `insert' for this, because a GC could happen
-   before we bcopy the stuff into the buffer, and relocate the string
+   before we copy the stuff into the buffer, and relocate the string
    without insert noticing.  */
 
 void
@@ -1182,7 +1146,7 @@ insert_from_gap (EMACS_INT nchars, EMACS_INT nbytes)
    into the current buffer.
 
    It does not work to use `insert' for this, because a malloc could happen
-   and relocate BUF's text before the bcopy happens.  */
+   and relocate BUF's text before the copy happens.  */
 
 void
 insert_from_buffer (struct buffer *buf,
@@ -1666,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;
@@ -1712,7 +1676,7 @@ replace_range_2 (EMACS_INT from, EMACS_INT from_byte,
     make_gap (insbytes - GAP_SIZE);
 
   /* Copy the replacement text into the buffer.  */
-  bcopy (ins, GPT_ADDR, insbytes);
+  memcpy (GPT_ADDR, ins, insbytes);
 
 #ifdef BYTE_COMBINING_DEBUG
   /* We have copied text into the gap, but we have not marked
@@ -2085,6 +2049,24 @@ 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)
+      && !inhibit_modification_hooks
+      && XMARKER (current_buffer->mark)->buffer
+      && 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 = XMARKER (current_buffer->mark)->charpos;
+      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)
@@ -2305,7 +2287,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;