]> code.delx.au - gnu-emacs/blobdiff - src/insdel.c
(Qinhibit_read_only): Declared.
[gnu-emacs] / src / insdel.c
index cd46d0f4dcf9a0aa8a54b7b27888824315a3a0d6..1058de734deae41003d0671aad63310e65e45998 100644 (file)
@@ -15,7 +15,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 
 #include <config.h>
@@ -209,11 +210,16 @@ gap_right (pos)
   QUIT;
 }
 
-/* Add `amount' to the position of every marker in the current buffer
-   whose current position is between `from' (exclusive) and `to' (inclusive).
+/* Add AMOUNT to the position of every marker in the current buffer
+   whose current position is between FROM (exclusive) and TO (inclusive).
+
    Also, any markers past the outside of that interval, in the direction
    of adjustment, are first moved back to the near end of the interval
-   and then adjusted by `amount'.  */
+   and then adjusted by AMOUNT.
+
+   When the latter adjustment is done, if AMOUNT is negative,
+   we record the adjustment for undo.  (This case happens only for
+   deletion.)  */
 
 static void
 adjust_markers (from, to, amount)
@@ -236,8 +242,14 @@ adjust_markers (from, to, amount)
        }
       else
        {
+         /* Here's the case where a marker is inside text being deleted.
+            AMOUNT can be negative for gap motion, too,
+            but then this range contains no markers.  */
          if (mpos > from + amount && mpos <= from)
-           mpos = from + amount;
+           {
+             record_marker_adjustment (marker, from + amount - mpos);
+             mpos = from + amount;
+           }
        }
       if (mpos > from && mpos <= to)
        mpos += amount;
@@ -271,7 +283,7 @@ adjust_markers_for_insert (pos, amount)
    a conceptual change in point as a marker.  In particular, point is
    not crossing any interval boundaries, so there's no need to use the
    usual SET_PT macro.  In fact it would be incorrect to do so, because
-   either the old or the new value of point is out of synch with the
+   either the old or the new value of point is out of sync with the
    current set of intervals.  */
 static void
 adjust_point (amount)
@@ -299,7 +311,7 @@ make_gap (increment)
      That won't work because so many places use `int'.  */
      
   if (Z - BEG + GAP_SIZE + increment
-      >= ((unsigned) 1 << (min (INTBITS, VALBITS) - 1)))
+      >= ((unsigned) 1 << (min (BITS_PER_INT, VALBITS) - 1)))
     error ("Buffer exceeds maximum size");
 
   BLOCK_INPUT;
@@ -654,6 +666,12 @@ del_range_1 (from, to, prepare)
   if (prepare)
     prepare_to_modify_buffer (from, to);
 
+  /* Relocate all markers pointing into the new, larger gap
+     to point at the end of the text before the gap.
+     This has to be done before recording the deletion,
+     so undo handles this after reinserting the text.  */
+  adjust_markers (to + GAP_SIZE, to + GAP_SIZE, - numdel - GAP_SIZE);
+
   record_delete (from, numdel);
   MODIFF++;
 
@@ -664,10 +682,6 @@ del_range_1 (from, to, prepare)
   /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
   offset_intervals (current_buffer, from, - numdel);
 
-  /* Relocate all markers pointing into the new, larger gap
-     to point at the end of the text before the gap.  */
-  adjust_markers (to + GAP_SIZE, to + GAP_SIZE, - numdel - GAP_SIZE);
-
   /* Adjust the overlay center as needed.  This must be done after
      adjusting the markers that bound the overlays.  */
   adjust_overlays_for_delete (from, numdel);
@@ -875,4 +889,9 @@ signal_after_change (pos, lendel, lenins)
                                 1,
                                 make_number (pos), make_number (pos + lenins),
                                 make_number (lendel));
+
+  /* After an insertion, call the text properties
+     insert-behind-hooks or insert-in-front-hooks.  */
+  if (lendel == 0)
+    report_interval_modification (pos, pos + lenins);
 }