]> code.delx.au - gnu-emacs/blobdiff - src/insdel.c
(PENDING_OUTPUT_COUNT) [__GNU_LIBRARY__]: Alternate definition for the GNU
[gnu-emacs] / src / insdel.c
index 35345440c2ad89a57c3512e0cc01774d0350f904..711e272da597174f5a71673bc022e6843b334805 100644 (file)
@@ -1,5 +1,5 @@
 /* Buffer insertion/deletion and gap motion for GNU Emacs.
-   Copyright (C) 1985, 1986 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,15 +18,12 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 
-#include "config.h"
+#include <config.h>
 #include "lisp.h"
 #include "intervals.h"
 #include "buffer.h"
 #include "window.h"
-
-/* Nonzero means don't allow protected fields to be modified.  */
-
-extern int check_protected_fields;
+#include "blockinput.h"
 
 /* Move gap to position `pos'.
    Note that this can quit!  */
@@ -249,7 +246,10 @@ make_gap (increment)
   /* If we have to get more space, get enough to last a while.  */
   increment += 2000;
 
+  BLOCK_INPUT;
   result = BUFFER_REALLOC (BEG_ADDR, (Z - BEG + GAP_SIZE + increment));
+  UNBLOCK_INPUT;
+
   if (result == 0)
     memory_full ();
   BEG_ADDR = result;
@@ -327,9 +327,10 @@ insert (string, length)
    before we bcopy the stuff into the buffer, and relocate the string
    without insert noticing.  */
 
-insert_from_string (string, pos, length)
+insert_from_string (string, pos, length, inherit)
      Lisp_Object string;
      register int pos, length;
+     int inherit;
 {
   register Lisp_Object temp;
   struct gcpro gcpro1;
@@ -365,8 +366,8 @@ insert_from_string (string, pos, length)
   Z += length;
 
   /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
-  graft_intervals_into_buffer (XSTRING (string)->intervals, point,
-                              current_buffer);
+  graft_intervals_into_buffer (XSTRING (string)->intervals, point, length,
+                              current_buffer, inherit);
 
   SET_PT (point + length);
 
@@ -407,12 +408,13 @@ insert_before_markers (string, length)
 
 /* Insert part of a Lisp string, relocating markers after.  */
 
-insert_from_string_before_markers (string, pos, length)
+insert_from_string_before_markers (string, pos, length, inherit)
      Lisp_Object string;
      register int pos, length;
+     int inherit;
 {
   register int opoint = point;
-  insert_from_string (string, pos, length);
+  insert_from_string (string, pos, length, inherit);
   adjust_markers (opoint - 1, opoint, length);
 }
 \f
@@ -473,9 +475,19 @@ del_range (from, to)
   signal_after_change (from, numdel, 0);
 }
 \f
-modify_region (start, end)
+/* Call this if you're about to change the region of BUFFER from START
+   to END.  This checks the read-only properties of the region, calls
+   the necessary modification hooks, and warns the next redisplay that
+   it should pay attention to that area.  */
+modify_region (buffer, start, end)
+     struct buffer *buffer;
      int start, end;
 {
+  struct buffer *old_buffer = current_buffer;
+
+  if (buffer != old_buffer)
+    set_buffer_internal (buffer);
+
   prepare_to_modify_buffer (start, end);
 
   if (start - 1 < beg_unchanged || unchanged_modified == MODIFF)
@@ -484,6 +496,9 @@ modify_region (start, end)
       || unchanged_modified == MODIFF)
     end_unchanged = Z - end;
   MODIFF++;
+
+  if (buffer != old_buffer)
+    set_buffer_internal (old_buffer);
 }
 
 /* Check that it is okay to modify the buffer between START and END.
@@ -497,14 +512,11 @@ prepare_to_modify_buffer (start, end)
   if (!NILP (current_buffer->read_only))
     Fbarf_if_buffer_read_only ();
 
-#if 0                          /* Superceded by interval code */
-  if (check_protected_fields)
-    Fregion_fields (start, end, Qnil, Qt);
-#endif
-
   /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
   verify_interval_modification (current_buffer, start, end);
 
+  verify_overlay_modification (start, end);
+
 #ifdef CLASH_DETECTION
   if (!NILP (current_buffer->filename)
       && current_buffer->save_modified >= MODIFF)
@@ -520,6 +532,8 @@ prepare_to_modify_buffer (start, end)
 #endif /* not CLASH_DETECTION */
 
   signal_before_change (start, end);
+
+  Vdeactivate_mark = Qt;
 }
 \f
 static Lisp_Object
@@ -536,7 +550,7 @@ after_change_function_restore (value)
   Vafter_change_function = value;
 }
 
-/* Signal a change to the buffer immediatly before it happens.
+/* Signal a change to the buffer immediately before it happens.
    START and END are the bounds of the text to be changed,
    as Lisp objects.  */
 
@@ -568,7 +582,7 @@ signal_before_change (start, end)
     }
 }
 
-/* Signal a change immediatly after it happens.
+/* Signal a change immediately after it happens.
    POS is the address of the start of the changed text.
    LENDEL is the number of characters of the text before the change.
    (Not the whole buffer; just the part that was changed.)