]> code.delx.au - gnu-emacs/blobdiff - src/insdel.c
Add pre-redisplay-function and rectangular region
[gnu-emacs] / src / insdel.c
index f746fd3433012d04ced2c2f24c2b4c61ea23e5d9..7e6182deb9169da131180a1c948952ccfde72148 100644 (file)
@@ -988,8 +988,7 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
 void
 insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail)
 {
-  int ins_charpos = GPT;
-  int ins_bytepos = GPT_BYTE;
+  ptrdiff_t ins_charpos = GPT, ins_bytepos = GPT_BYTE;
 
   if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
     nchars = nbytes;
@@ -1057,6 +1056,9 @@ insert_from_buffer_1 (struct buffer *buf,
   ptrdiff_t outgoing_nbytes = incoming_nbytes;
   INTERVAL intervals;
 
+  if (nchars == 0)
+    return;
+
   /* Make OUTGOING_NBYTES describe the text
      as it will be inserted in this buffer.  */
 
@@ -1776,6 +1778,8 @@ modify_text (ptrdiff_t start, ptrdiff_t end)
   bset_point_before_scroll (current_buffer, Qnil);
 }
 
+Lisp_Object Qregion_extract_function;
+
 /* Check that it is okay to modify the buffer between START and END,
    which are char positions.
 
@@ -1841,6 +1845,7 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
 #endif /* not CLASH_DETECTION */
 
   /* If `select-active-regions' is non-nil, save the region text.  */
+  /* FIXME: Move this to Elisp (via before-change-functions).  */
   if (!NILP (BVAR (current_buffer, mark_active))
       && !inhibit_modification_hooks
       && XMARKER (BVAR (current_buffer, mark))->buffer
@@ -1852,10 +1857,8 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t end,
     {
       ptrdiff_t b = marker_position (BVAR (current_buffer, mark));
       ptrdiff_t 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);
+      Vsaved_region_selection
+       = call1 (Fsymbol_value (Qregion_extract_function), Qnil);
     }
 
   signal_before_change (start, end, preserve_ptr);
@@ -2200,5 +2203,7 @@ as well as hooks attached to text properties and overlays.  */);
   inhibit_modification_hooks = 0;
   DEFSYM (Qinhibit_modification_hooks, "inhibit-modification-hooks");
 
+  DEFSYM (Qregion_extract_function, "region-extract-function");
+
   defsubr (&Scombine_after_change_execute);
 }