changeset 6739:6b0dd4aeca67

(insert_1): New function, extracted from insert. (insert_from_string_1): Likewise, taken from insert_from_string. (insert, insert_from_string): Call the new functions. (insert_before_markers, insert_from_string_before_markers): Adjust the markers before calling the after-change function.
author Karl Heuer <kwzh@gnu.org>
date Fri, 08 Apr 1994 00:44:35 +0000
parents 91a5e1cd14c7
children 255869831639
files src/insdel.c
diffstat 1 files changed, 42 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/insdel.c	Fri Apr 08 00:18:37 1994 +0000
+++ b/src/insdel.c	Fri Apr 08 00:44:35 1994 +0000
@@ -25,6 +25,9 @@
 #include "window.h"
 #include "blockinput.h"
 
+static void insert_1 ();
+static void insert_from_string_1 ();
+
 /* Move gap to position `pos'.
    Note that this can quit!  */
 
@@ -284,10 +287,19 @@
      register unsigned char *string;
      register length;
 {
-  register Lisp_Object temp;
+  if (length > 0)
+    {
+      insert_1 (string, length);
+      signal_after_change (point-length, 0, length);
+    }
+}
 
-  if (length < 1)
-    return;
+static void
+insert_1 (string, length)
+     register unsigned char *string;
+     register length;
+{
+  register Lisp_Object temp;
 
   /* Make sure point-max won't overflow after this insertion.  */
   XSET (temp, Lisp_Int, length + Z);
@@ -314,8 +326,6 @@
   ZV += length;
   Z += length;
   SET_PT (point + length);
-
-  signal_after_change (point-length, 0, length);
 }
 
 /* Insert the part of the text of STRING, a Lisp object assumed to be
@@ -332,12 +342,22 @@
      register int pos, length;
      int inherit;
 {
+  if (length > 0)
+    {
+      insert_from_string_1 (string, pos, length, inherit);
+      signal_after_change (point-length, 0, length);
+    }
+}
+
+static void
+insert_from_string_1 (string, pos, length, inherit)
+     Lisp_Object string;
+     register int pos, length;
+     int inherit;
+{
   register Lisp_Object temp;
   struct gcpro gcpro1;
 
-  if (length < 1)
-    return;
-
   /* Make sure point-max won't overflow after this insertion.  */
   XSET (temp, Lisp_Int, length + Z);
   if (length + Z != XINT (temp))
@@ -370,8 +390,6 @@
 			       current_buffer, inherit);
 
   SET_PT (point + length);
-
-  signal_after_change (point-length, 0, length);
 }
 
 /* Insert the character C before point */
@@ -401,9 +419,13 @@
      unsigned char *string;
      register int length;
 {
-  register int opoint = point;
-  insert (string, length);
-  adjust_markers (opoint - 1, opoint, length);
+  if (length > 0)
+    {
+      register int opoint = point;
+      insert_1 (string, length);
+      adjust_markers (opoint - 1, opoint, length);
+      signal_after_change (point-length, 0, length);
+    }
 }
 
 /* Insert part of a Lisp string, relocating markers after.  */
@@ -413,9 +435,13 @@
      register int pos, length;
      int inherit;
 {
-  register int opoint = point;
-  insert_from_string (string, pos, length, inherit);
-  adjust_markers (opoint - 1, opoint, length);
+  if (length > 0)
+    {
+      register int opoint = point;
+      insert_from_string_1 (string, pos, length, inherit);
+      adjust_markers (opoint - 1, opoint, length);
+      signal_after_change (point-length, 0, length);
+    }
 }
 
 /* Delete characters in current buffer