changeset 51671:54f0e48f9f7d

(check_markers, adjust_markers_for_delete) (adjust_markers_for_insert, adjust_markers_for_replace) (prepare_to_modify_buffer, RESTORE_VALUE): Update for new types.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 26 Jun 2003 23:17:29 +0000
parents beceb827c1ce
children 018c85ec9a1e
files src/insdel.c
diffstat 1 files changed, 22 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/insdel.c	Thu Jun 26 23:17:13 2003 +0000
+++ b/src/insdel.c	Thu Jun 26 23:17:29 2003 +0000
@@ -1,5 +1,5 @@
 /* Buffer insertion/deletion and gap motion for GNU Emacs.
-   Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 2001
+   Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 01, 2003
    Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -79,23 +79,19 @@
 void
 check_markers ()
 {
-  register Lisp_Object tail;
+  register struct Lisp_Marker *tail;
   int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
 
-  tail = BUF_MARKERS (current_buffer);
-
-  while (! NILP (tail))
+  for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
     {
-      if (XMARKER (tail)->buffer->text != current_buffer->text)
+      if (tail->buffer->text != current_buffer->text)
 	abort ();
-      if (XMARKER (tail)->charpos > Z)
-	abort ();
-      if (XMARKER (tail)->bytepos > Z_BYTE)
+      if (tail->charpos > Z)
 	abort ();
-      if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (XMARKER (tail)->bytepos)))
+      if (tail->bytepos > Z_BYTE)
 	abort ();
-
-      tail = XMARKER (tail)->chain;
+      if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (tail->bytepos)))
+	abort ();
     }
 }
 
@@ -350,11 +346,8 @@
   register struct Lisp_Marker *m;
   register int charpos;
 
-  marker = BUF_MARKERS (current_buffer);
-
-  while (!NILP (marker))
+  for (m = BUF_MARKERS (current_buffer); m; m = m->next)
     {
-      m = XMARKER (marker);
       charpos = m->charpos;
 
       if (charpos > Z)
@@ -371,16 +364,19 @@
       else if (charpos > from)
 	{
 	  if (! m->insertion_type)
-	    /* Normal markers will end up at the beginning of the
+	    { /* Normal markers will end up at the beginning of the
 	       re-inserted text after undoing a deletion, and must be
 	       adjusted to move them to the correct place.  */
+	      XSETMISC (marker, m);
 	    record_marker_adjustment (marker, from - charpos);
+	    }
 	  else if (charpos < to)
-	    /* Before-insertion markers will automatically move forward
+	    { /* Before-insertion markers will automatically move forward
 	       upon re-inserting the deleted text, so we have to arrange
 	       for them to move backward to the correct position.  */
+	      XSETMISC (marker, m);
 	    record_marker_adjustment (marker, charpos - to);
-
+	    }
 	  m->charpos = from;
 	  m->bytepos = from_byte;
 	}
@@ -392,10 +388,9 @@
 	     incorrectly make MARKER move forward, so we arrange for it
 	     to then move backward to the correct place at the beginning
 	     of the deleted region.  */
+	  XSETMISC (marker, m);
 	  record_marker_adjustment (marker, to - from);
 	}
-
-      marker = m->chain;
     }
 }
 
@@ -413,17 +408,13 @@
      register int from, from_byte, to, to_byte;
      int before_markers;
 {
-  Lisp_Object marker;
+  struct Lisp_Marker *m;
   int adjusted = 0;
   int nchars = to - from;
   int nbytes = to_byte - from_byte;
 
-  marker = BUF_MARKERS (current_buffer);
-
-  while (!NILP (marker))
+  for (m = BUF_MARKERS (current_buffer); m; m = m->next)
     {
-      register struct Lisp_Marker *m = XMARKER (marker);
-
       /* In a single-byte buffer, a marker's two positions must be
 	 equal.  */
       if (Z == Z_BYTE)
@@ -447,8 +438,6 @@
 	  m->bytepos += nbytes;
 	  m->charpos += nchars;
 	}
-
-      marker = m->chain;
     }
 
   /* Adjusting only markers whose insertion-type is t may result in
@@ -490,15 +479,13 @@
 			    new_chars, new_bytes)
      int from, from_byte, old_chars, old_bytes, new_chars, new_bytes;
 {
-  Lisp_Object marker = BUF_MARKERS (current_buffer);
+  register struct Lisp_Marker *m;
   int prev_to_byte = from_byte + old_bytes;
   int diff_chars = new_chars - old_chars;
   int diff_bytes = new_bytes - old_bytes;
 
-  while (!NILP (marker))
+  for (m = BUF_MARKERS (current_buffer); m; m = m->next)
     {
-      register struct Lisp_Marker *m = XMARKER (marker);
-
       if (m->bytepos >= prev_to_byte)
 	{
 	  m->charpos += diff_chars;
@@ -509,8 +496,6 @@
 	  m->charpos = from;
 	  m->bytepos = from_byte;
 	}
-
-      marker = m->chain;
     }
 
   CHECK_MARKERS ();
@@ -1930,7 +1915,7 @@
 	  GCPRO1 (preserve_marker);
 	  verify_interval_modification (current_buffer, start, end);
 	  *preserve_ptr = marker_position (preserve_marker);
-	  unchain_marker (preserve_marker);
+	  unchain_marker (XMARKER (preserve_marker));
 	  UNGCPRO;
 	}
       else
@@ -1978,7 +1963,7 @@
   if (! NILP (preserve_marker))					\
     {								\
       *preserve_ptr = marker_position (preserve_marker);	\
-      unchain_marker (preserve_marker);				\
+      unchain_marker (XMARKER (preserve_marker));		\
     }
 
 #define PRESERVE_START_END			\