emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/buffer.c


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/src/buffer.c
Date: Wed, 09 Jul 2003 11:09:13 -0400

Index: emacs/src/buffer.c
diff -c emacs/src/buffer.c:1.430 emacs/src/buffer.c:1.431
*** emacs/src/buffer.c:1.430    Tue Jul  8 18:09:23 2003
--- emacs/src/buffer.c  Wed Jul  9 11:09:12 2003
***************
*** 183,189 ****
  
  static void alloc_buffer_text P_ ((struct buffer *, size_t));
  static void free_buffer_text P_ ((struct buffer *b));
! static Lisp_Object copy_overlays P_ ((struct buffer *, Lisp_Object));
  static void modify_overlay P_ ((struct buffer *, int, int));
  
  
--- 183,189 ----
  
  static void alloc_buffer_text P_ ((struct buffer *, size_t));
  static void free_buffer_text P_ ((struct buffer *b));
! static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct 
Lisp_Overlay *));
  static void modify_overlay P_ ((struct buffer *, int, int));
  
  
***************
*** 434,454 ****
  /* Return a list of overlays which is a copy of the overlay list
     LIST, but for buffer B.  */
  
! static Lisp_Object
  copy_overlays (b, list)
       struct buffer *b;
!      Lisp_Object list;
  {
!   Lisp_Object result, buffer;
  
    XSETBUFFER (buffer, b);
  
!   for (result = Qnil; CONSP (list); list = XCDR (list))
      {
        Lisp_Object overlay, start, end, old_overlay;
        int charpos;
  
!       old_overlay = XCAR (list);
        charpos = marker_position (OVERLAY_START (old_overlay));
        start = Fmake_marker ();
        Fset_marker (start, make_number (charpos), buffer);
--- 434,455 ----
  /* Return a list of overlays which is a copy of the overlay list
     LIST, but for buffer B.  */
  
! static struct Lisp_Overlay *
  copy_overlays (b, list)
       struct buffer *b;
!      struct Lisp_Overlay *list;
  {
!   Lisp_Object buffer;
!   struct Lisp_Overlay *result = NULL, *tail = NULL;
  
    XSETBUFFER (buffer, b);
  
!   for (; list; list = list->next)
      {
        Lisp_Object overlay, start, end, old_overlay;
        int charpos;
  
!       XSETMISC (old_overlay, list);
        charpos = marker_position (OVERLAY_START (old_overlay));
        start = Fmake_marker ();
        Fset_marker (start, make_number (charpos), buffer);
***************
*** 466,476 ****
        OVERLAY_START (overlay) = start;
        OVERLAY_END (overlay) = end;
        OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay));
  
!       result = Fcons (overlay, result);
      }
  
!   return Fnreverse (result);
  }
  
  
--- 467,481 ----
        OVERLAY_START (overlay) = start;
        OVERLAY_END (overlay) = end;
        OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay));
+       XOVERLAY (overlay)->next = NULL;
  
!       if (tail)
!       tail = tail->next = XOVERLAY (overlay);
!       else
!       result = tail = XOVERLAY (overlay);
      }
  
!   return result;
  }
  
  
***************
*** 646,653 ****
    b->auto_save_failure_time = -1;
    b->auto_save_file_name = Qnil;
    b->read_only = Qnil;
!   b->overlays_before = Qnil;
!   b->overlays_after = Qnil;
    b->overlay_center = BEG;
    b->mark_active = Qnil;
    b->point_before_scroll = Qnil;
--- 651,658 ----
    b->auto_save_failure_time = -1;
    b->auto_save_file_name = Qnil;
    b->read_only = Qnil;
!   b->overlays_before = NULL;
!   b->overlays_after = NULL;
    b->overlay_center = BEG;
    b->mark_active = Qnil;
    b->point_before_scroll = Qnil;
***************
*** 2428,2434 ****
       int *prev_ptr;
       int change_req;
  {
!   Lisp_Object tail, overlay, start, end;
    int idx = 0;
    int len = *len_ptr;
    Lisp_Object *vec = *vec_ptr;
--- 2433,2440 ----
       int *prev_ptr;
       int change_req;
  {
!   Lisp_Object overlay, start, end;
!   struct Lisp_Overlay *tail;
    int idx = 0;
    int len = *len_ptr;
    Lisp_Object *vec = *vec_ptr;
***************
*** 2436,2448 ****
    int prev = BEGV;
    int inhibit_storing = 0;
  
!   for (tail = current_buffer->overlays_before;
!        GC_CONSP (tail);
!        tail = XCDR (tail))
      {
        int startpos, endpos;
  
!       overlay = XCAR (tail);
  
        start = OVERLAY_START (overlay);
        end = OVERLAY_END (overlay);
--- 2442,2452 ----
    int prev = BEGV;
    int inhibit_storing = 0;
  
!   for (tail = current_buffer->overlays_before; tail; tail = tail->next)
      {
        int startpos, endpos;
  
!       XSETMISC (overlay, tail);
  
        start = OVERLAY_START (overlay);
        end = OVERLAY_END (overlay);
***************
*** 2489,2501 ****
        next = startpos;
      }
  
!   for (tail = current_buffer->overlays_after;
!        GC_CONSP (tail);
!        tail = XCDR (tail))
      {
        int startpos, endpos;
  
!       overlay = XCAR (tail);
  
        start = OVERLAY_START (overlay);
        end = OVERLAY_END (overlay);
--- 2493,2503 ----
        next = startpos;
      }
  
!   for (tail = current_buffer->overlays_after; tail; tail = tail->next)
      {
        int startpos, endpos;
  
!       XSETMISC (overlay, tail);
  
        start = OVERLAY_START (overlay);
        end = OVERLAY_END (overlay);
***************
*** 2574,2580 ****
       int *next_ptr;
       int *prev_ptr;
  {
!   Lisp_Object tail, overlay, ostart, oend;
    int idx = 0;
    int len = *len_ptr;
    Lisp_Object *vec = *vec_ptr;
--- 2576,2583 ----
       int *next_ptr;
       int *prev_ptr;
  {
!   Lisp_Object overlay, ostart, oend;
!   struct Lisp_Overlay *tail;
    int idx = 0;
    int len = *len_ptr;
    Lisp_Object *vec = *vec_ptr;
***************
*** 2582,2594 ****
    int prev = BEGV;
    int inhibit_storing = 0;
  
!   for (tail = current_buffer->overlays_before;
!        GC_CONSP (tail);
!        tail = XCDR (tail))
      {
        int startpos, endpos;
  
!       overlay = XCAR (tail);
  
        ostart = OVERLAY_START (overlay);
        oend = OVERLAY_END (overlay);
--- 2585,2595 ----
    int prev = BEGV;
    int inhibit_storing = 0;
  
!   for (tail = current_buffer->overlays_before; tail; tail = tail->next)
      {
        int startpos, endpos;
  
!       XSETMISC (overlay, tail);
  
        ostart = OVERLAY_START (overlay);
        oend = OVERLAY_END (overlay);
***************
*** 2632,2644 ****
        next = startpos;
      }
  
!   for (tail = current_buffer->overlays_after;
!        GC_CONSP (tail);
!        tail = XCDR (tail))
      {
        int startpos, endpos;
  
!       overlay = XCAR (tail);
  
        ostart = OVERLAY_START (overlay);
        oend = OVERLAY_END (overlay);
--- 2633,2643 ----
        next = startpos;
      }
  
!   for (tail = current_buffer->overlays_after; tail; tail = tail->next)
      {
        int startpos, endpos;
  
!       XSETMISC (overlay, tail);
  
        ostart = OVERLAY_START (overlay);
        oend = OVERLAY_END (overlay);
***************
*** 2724,2737 ****
  overlay_touches_p (pos)
       int pos;
  {
!   Lisp_Object tail, overlay;
  
!   for (tail = current_buffer->overlays_before; GC_CONSP (tail);
!        tail = XCDR (tail))
      {
        int endpos;
  
!       overlay = XCAR (tail);
        if (!GC_OVERLAYP (overlay))
        abort ();
  
--- 2723,2736 ----
  overlay_touches_p (pos)
       int pos;
  {
!   Lisp_Object overlay;
!   struct Lisp_Overlay *tail;
  
!   for (tail = current_buffer->overlays_before; tail; tail = tail->next)
      {
        int endpos;
  
!       XSETMISC (overlay ,tail);
        if (!GC_OVERLAYP (overlay))
        abort ();
  
***************
*** 2742,2753 ****
        return 1;
      }
  
!   for (tail = current_buffer->overlays_after; GC_CONSP (tail);
!        tail = XCDR (tail))
      {
        int startpos;
  
!       overlay = XCAR (tail);
        if (!GC_OVERLAYP (overlay))
        abort ();
  
--- 2741,2751 ----
        return 1;
      }
  
!   for (tail = current_buffer->overlays_after; tail; tail = tail->next)
      {
        int startpos;
  
!       XSETMISC (overlay, tail);
        if (!GC_OVERLAYP (overlay))
        abort ();
  
***************
*** 2946,2960 ****
       struct window *w;
       unsigned char **pstr;
  {
!   Lisp_Object ov, overlay, window, str;
    int startpos, endpos;
    int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
  
    overlay_heads.used = overlay_heads.bytes = 0;
    overlay_tails.used = overlay_tails.bytes = 0;
!   for (ov = current_buffer->overlays_before; CONSP (ov); ov = XCDR (ov))
      {
!       overlay = XCAR (ov);
        eassert (OVERLAYP (overlay));
  
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
--- 2944,2959 ----
       struct window *w;
       unsigned char **pstr;
  {
!   Lisp_Object overlay, window, str;
!   struct Lisp_Overlay *ov;
    int startpos, endpos;
    int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
  
    overlay_heads.used = overlay_heads.bytes = 0;
    overlay_tails.used = overlay_tails.bytes = 0;
!   for (ov = current_buffer->overlays_before; ov; ov = ov->next)
      {
!       XSETMISC (overlay, ov);
        eassert (OVERLAYP (overlay));
  
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
***************
*** 2980,2989 ****
                               Foverlay_get (overlay, Qpriority),
                               endpos - startpos);
      }
!   for (ov = current_buffer->overlays_after; CONSP (ov); ov = XCDR (ov))
      {
!       overlay = XCAR (ov);
!       eassert (!OVERLAYP (overlay));
  
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
        endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
--- 2979,2988 ----
                               Foverlay_get (overlay, Qpriority),
                               endpos - startpos);
      }
!   for (ov = current_buffer->overlays_after; ov; ov = ov->next)
      {
!       XSETMISC (overlay, ov);
!       eassert (OVERLAYP (overlay));
  
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
        endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
***************
*** 3070,3089 ****
       struct buffer *buf;
       EMACS_INT pos;
  {
!   Lisp_Object overlay, tail, next, prev, beg, end;
  
    /* See if anything in overlays_before should move to overlays_after.  */
  
    /* We don't strictly need prev in this loop; it should always be nil.
       But we use it for symmetry and in case that should cease to be true
       with some future change.  */
!   prev = Qnil;
!   for (tail = buf->overlays_before;
!        CONSP (tail);
!        prev = tail, tail = next)
      {
!       next = XCDR (tail);
!       overlay = XCAR (tail);
  
        /* If the overlay is not valid, get rid of it.  */
        if (!OVERLAY_VALID (overlay))
--- 3069,3087 ----
       struct buffer *buf;
       EMACS_INT pos;
  {
!   Lisp_Object overlay, beg, end;
!   struct Lisp_Overlay *prev, *tail, *next;
  
    /* See if anything in overlays_before should move to overlays_after.  */
  
    /* We don't strictly need prev in this loop; it should always be nil.
       But we use it for symmetry and in case that should cease to be true
       with some future change.  */
!   prev = NULL;
!   for (tail = buf->overlays_before; tail; prev = tail, tail = next)
      {
!       next = tail->next;
!       XSETMISC (overlay, tail);
  
        /* If the overlay is not valid, get rid of it.  */
        if (!OVERLAY_VALID (overlay))
***************
*** 3108,3131 ****
        {
          /* OVERLAY needs to be moved.  */
          int where = OVERLAY_POSITION (beg);
!         Lisp_Object other, other_prev;
  
          /* Splice the cons cell TAIL out of overlays_before.  */
!         if (!NILP (prev))
!           XSETCDR (prev, next);
          else
            buf->overlays_before = next;
  
          /* Search thru overlays_after for where to put it.  */
!         other_prev = Qnil;
!         for (other = buf->overlays_after;
!              CONSP (other);
!              other_prev = other, other = XCDR (other))
            {
              Lisp_Object otherbeg, otheroverlay;
  
!             otheroverlay = XCAR (other);
!             eassert (! OVERLAY_VALID (otheroverlay));
  
              otherbeg = OVERLAY_START (otheroverlay);
              if (OVERLAY_POSITION (otherbeg) >= where)
--- 3106,3128 ----
        {
          /* OVERLAY needs to be moved.  */
          int where = OVERLAY_POSITION (beg);
!         struct Lisp_Overlay *other, *other_prev;
  
          /* Splice the cons cell TAIL out of overlays_before.  */
!         if (prev)
!           prev->next = next;
          else
            buf->overlays_before = next;
  
          /* Search thru overlays_after for where to put it.  */
!         other_prev = NULL;
!         for (other = buf->overlays_after; other;
!              other_prev = other, other = other->next)
            {
              Lisp_Object otherbeg, otheroverlay;
  
!             XSETMISC (otheroverlay, other);
!             eassert (OVERLAY_VALID (otheroverlay));
  
              otherbeg = OVERLAY_START (otheroverlay);
              if (OVERLAY_POSITION (otherbeg) >= where)
***************
*** 3133,3141 ****
            }
  
          /* Add TAIL to overlays_after before OTHER.  */
!         XSETCDR (tail, other);
!         if (!NILP (other_prev))
!           XSETCDR (other_prev, tail);
          else
            buf->overlays_after = tail;
          tail = prev;
--- 3130,3138 ----
            }
  
          /* Add TAIL to overlays_after before OTHER.  */
!         tail->next = other;
!         if (other_prev)
!           other_prev->next = tail;
          else
            buf->overlays_after = tail;
          tail = prev;
***************
*** 3148,3160 ****
      }
  
    /* See if anything in overlays_after should be in overlays_before.  */
!   prev = Qnil;
!   for (tail = buf->overlays_after;
!        CONSP (tail);
!        prev = tail, tail = next)
      {
!       next = XCDR (tail);
!       overlay = XCAR (tail);
  
        /* If the overlay is not valid, get rid of it.  */
        if (!OVERLAY_VALID (overlay))
--- 3145,3155 ----
      }
  
    /* See if anything in overlays_after should be in overlays_before.  */
!   prev = NULL;
!   for (tail = buf->overlays_after; tail; prev = tail, tail = next)
      {
!       next = tail->next;
!       XSETMISC (overlay, tail);
  
        /* If the overlay is not valid, get rid of it.  */
        if (!OVERLAY_VALID (overlay))
***************
*** 3184,3207 ****
        {
          /* OVERLAY needs to be moved.  */
          int where = OVERLAY_POSITION (end);
!         Lisp_Object other, other_prev;
  
          /* Splice the cons cell TAIL out of overlays_after.  */
!         if (!NILP (prev))
!           XSETCDR (prev, next);
          else
            buf->overlays_after = next;
  
          /* Search thru overlays_before for where to put it.  */
!         other_prev = Qnil;
!         for (other = buf->overlays_before;
!              CONSP (other);
!              other_prev = other, other = XCDR (other))
            {
              Lisp_Object otherend, otheroverlay;
  
!             otheroverlay = XCAR (other);
!             eassert (! OVERLAY_VALID (otheroverlay));
  
              otherend = OVERLAY_END (otheroverlay);
              if (OVERLAY_POSITION (otherend) <= where)
--- 3179,3201 ----
        {
          /* OVERLAY needs to be moved.  */
          int where = OVERLAY_POSITION (end);
!         struct Lisp_Overlay *other, *other_prev;
  
          /* Splice the cons cell TAIL out of overlays_after.  */
!         if (prev)
!           prev->next = next;
          else
            buf->overlays_after = next;
  
          /* Search thru overlays_before for where to put it.  */
!         other_prev = NULL;
!         for (other = buf->overlays_before; other;
!              other_prev = other, other = other->next)
            {
              Lisp_Object otherend, otheroverlay;
  
!             XSETMISC (otheroverlay, other);
!             eassert (OVERLAY_VALID (otheroverlay));
  
              otherend = OVERLAY_END (otheroverlay);
              if (OVERLAY_POSITION (otherend) <= where)
***************
*** 3209,3217 ****
            }
  
          /* Add TAIL to overlays_before before OTHER.  */
!         XSETCDR (tail, other);
!         if (!NILP (other_prev))
!           XSETCDR (other_prev, tail);
          else
            buf->overlays_before = tail;
          tail = prev;
--- 3203,3211 ----
            }
  
          /* Add TAIL to overlays_before before OTHER.  */
!         tail->next = other;
!         if (other_prev)
!           other_prev->next = tail;
          else
            buf->overlays_before = tail;
          tail = prev;
***************
*** 3265,3279 ****
       register int start, end;
  {
    Lisp_Object overlay;
!   Lisp_Object before_list, after_list;
    /* These are either nil, indicating that before_list or after_list
       should be assigned, or the cons cell the cdr of which should be
       assigned.  */
!   Lisp_Object beforep = Qnil, afterp = Qnil;
    /* 'Parent', likewise, indicates a cons cell or
       current_buffer->overlays_before or overlays_after, depending
       which loop we're in.  */
!   Lisp_Object tail, parent;
    int startpos, endpos;
  
    /* This algorithm shifts links around instead of consing and GCing.
--- 3259,3273 ----
       register int start, end;
  {
    Lisp_Object overlay;
!   struct Lisp_Overlay *before_list, *after_list;
    /* These are either nil, indicating that before_list or after_list
       should be assigned, or the cons cell the cdr of which should be
       assigned.  */
!   struct Lisp_Overlay *beforep = NULL, *afterp = NULL;
    /* 'Parent', likewise, indicates a cons cell or
       current_buffer->overlays_before or overlays_after, depending
       which loop we're in.  */
!   struct Lisp_Overlay *tail, *parent;
    int startpos, endpos;
  
    /* This algorithm shifts links around instead of consing and GCing.
***************
*** 3283,3291 ****
       (after_list) if it is, is still uninitialized.  So it's not a bug
       that before_list isn't initialized, although it may look
       strange.  */
!   for (parent = Qnil, tail = current_buffer->overlays_before; CONSP (tail);)
      {
!       overlay = XCAR (tail);
        endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
        if (endpos < start)
        break;
--- 3277,3285 ----
       (after_list) if it is, is still uninitialized.  So it's not a bug
       that before_list isn't initialized, although it may look
       strange.  */
!   for (parent = NULL, tail = current_buffer->overlays_before; tail;)
      {
!       XSETMISC (overlay, tail);
        endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
        if (endpos < start)
        break;
***************
*** 3307,3338 ****
             recenter_overlay_lists will move it to the right place.  */
          if (endpos < current_buffer->overlay_center)
            {
!             if (NILP (afterp))
                after_list = tail;
              else
!               XSETCDR (afterp, tail);
              afterp = tail;
            }
          else
            {
!             if (NILP (beforep))
                before_list = tail;
              else
!               XSETCDR (beforep, tail);
              beforep = tail;
            }
!         if (NILP (parent))
!           current_buffer->overlays_before = XCDR (tail);
          else
!           XSETCDR (parent, XCDR (tail));
!         tail = XCDR (tail);
        }
        else
!       parent = tail, tail = XCDR (parent);
      }
!   for (parent = Qnil, tail = current_buffer->overlays_after; CONSP (tail);)
      {
!       overlay = XCAR (tail);
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
        if (startpos >= end)
        break;
--- 3301,3332 ----
             recenter_overlay_lists will move it to the right place.  */
          if (endpos < current_buffer->overlay_center)
            {
!             if (!afterp)
                after_list = tail;
              else
!               afterp->next = tail;
              afterp = tail;
            }
          else
            {
!             if (!beforep)
                before_list = tail;
              else
!               beforep->next = tail;
              beforep = tail;
            }
!         if (!parent)
!           current_buffer->overlays_before = tail->next;
          else
!           parent->next = tail->next;
!         tail = tail->next;
        }
        else
!       parent = tail, tail = parent->next;
      }
!   for (parent = NULL, tail = current_buffer->overlays_after; tail;)
      {
!       XSETMISC (overlay, tail);
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
        if (startpos >= end)
        break;
***************
*** 3351,3392 ****
            }
          if (endpos < current_buffer->overlay_center)
            {
!             if (NILP (afterp))
                after_list = tail;
              else
!               XSETCDR (afterp, tail);
              afterp = tail;
            }
          else
            {
!             if (NILP (beforep))
                before_list = tail;
              else
!               XSETCDR (beforep, tail);
              beforep = tail;
            }
!         if (NILP (parent))
!           current_buffer->overlays_after = XCDR (tail);
          else
!           XSETCDR (parent, XCDR (tail));
!         tail = XCDR (tail);
        }
        else
!       parent = tail, tail = XCDR (parent);
      }
  
    /* Splice the constructed (wrong) lists into the buffer's lists,
       and let the recenter function make it sane again.  */
!   if (!NILP (beforep))
      {
!       XSETCDR (beforep, current_buffer->overlays_before);
        current_buffer->overlays_before = before_list;
      }
    recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
  
!   if (!NILP (afterp))
      {
!       XSETCDR (afterp, current_buffer->overlays_after);
        current_buffer->overlays_after = after_list;
      }
    recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
--- 3345,3386 ----
            }
          if (endpos < current_buffer->overlay_center)
            {
!             if (!afterp)
                after_list = tail;
              else
!               afterp->next = tail;
              afterp = tail;
            }
          else
            {
!             if (!beforep)
                before_list = tail;
              else
!               beforep->next = tail;
              beforep = tail;
            }
!         if (!parent)
!           current_buffer->overlays_after = tail->next;
          else
!           parent->next = tail->next;
!         tail = tail->next;
        }
        else
!       parent = tail, tail = parent->next;
      }
  
    /* Splice the constructed (wrong) lists into the buffer's lists,
       and let the recenter function make it sane again.  */
!   if (beforep)
      {
!       beforep->next = current_buffer->overlays_before;
        current_buffer->overlays_before = before_list;
      }
    recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
  
!   if (afterp)
      {
!       afterp->next = current_buffer->overlays_after;
        current_buffer->overlays_after = after_list;
      }
    recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
***************
*** 3409,3417 ****
       struct buffer *bp;
       EMACS_INT prev, pos;
  {
!   /* If parent is nil, replace overlays_before; otherwise, XCDR(parent).  */
!   Lisp_Object tail = bp->overlays_before, parent = Qnil;
!   Lisp_Object right_pair;
    EMACS_INT end;
  
    /* After the insertion, the several overlays may be in incorrect
--- 3403,3411 ----
       struct buffer *bp;
       EMACS_INT prev, pos;
  {
!   /* If parent is nil, replace overlays_before; otherwise, parent->next.  */
!   struct Lisp_Overlay *tail = bp->overlays_before, *parent = NULL, 
*right_pair;
!   Lisp_Object tem;
    EMACS_INT end;
  
    /* After the insertion, the several overlays may be in incorrect
***************
*** 3425,3484 ****
       in.  It is where an overlay which end before POS exists. (i.e. an
       overlay whose ending marker is after-insertion-marker if disorder
       exists).  */
!   while (!NILP (tail)
!        && ((end = OVERLAY_POSITION (OVERLAY_END (XCAR (tail))))
!            >= pos))
      {
        parent = tail;
!       tail = XCDR (tail);
      }
  
    /* If we don't find such an overlay,
       or the found one ends before PREV,
       or the found one is the last one in the list,
       we don't have to fix anything.  */
!   if (NILP (tail)
!       || end < prev
!       || NILP (XCDR (tail)))
      return;
  
    right_pair = parent;
    parent = tail;
!   tail = XCDR (tail);
  
    /* Now, end position of overlays in the list TAIL should be before
       or equal to PREV.  In the loop, an overlay which ends at POS is
       moved ahead to the place indicated by the CDR of RIGHT_PAIR.  If
       we found an overlay which ends before PREV, the remaining
       overlays are in correct order.  */
!   while (!NILP (tail))
      {
!       end = OVERLAY_POSITION (OVERLAY_END (XCAR (tail)));
  
        if (end == pos)
        {                       /* This overlay is disordered. */
!         Lisp_Object found = tail;
  
          /* Unlink the found overlay.  */
!         tail = XCDR (found);
!         XSETCDR (parent, tail);
          /* Move an overlay at RIGHT_PLACE to the next of the found one,
             and link it into the right place.  */
!         if (NILP (right_pair))
            {
!             XSETCDR (found, bp->overlays_before);
              bp->overlays_before = found;
            }
          else
            {
!             XSETCDR (found, XCDR (right_pair));
!             XSETCDR (right_pair, found);
            }
        }
        else if (end == prev)
        {
          parent = tail;
!         tail = XCDR (tail);
        }
        else                    /* No more disordered overlay. */
        break;
--- 3419,3477 ----
       in.  It is where an overlay which end before POS exists. (i.e. an
       overlay whose ending marker is after-insertion-marker if disorder
       exists).  */
!   while (tail
!        && (XSETMISC (tem, tail),
!            (end = OVERLAY_POSITION (OVERLAY_END (tem))) >= pos))
      {
        parent = tail;
!       tail = tail->next;
      }
  
    /* If we don't find such an overlay,
       or the found one ends before PREV,
       or the found one is the last one in the list,
       we don't have to fix anything.  */
!   if (tail || end < prev || !tail->next)
      return;
  
    right_pair = parent;
    parent = tail;
!   tail = tail->next;
  
    /* Now, end position of overlays in the list TAIL should be before
       or equal to PREV.  In the loop, an overlay which ends at POS is
       moved ahead to the place indicated by the CDR of RIGHT_PAIR.  If
       we found an overlay which ends before PREV, the remaining
       overlays are in correct order.  */
!   while (tail)
      {
!       XSETMISC (tem, tail);
!       end = OVERLAY_POSITION (OVERLAY_END (tem));
  
        if (end == pos)
        {                       /* This overlay is disordered. */
!         struct Lisp_Overlay *found = tail;
  
          /* Unlink the found overlay.  */
!         tail = found->next;
!         parent->next = tail;
          /* Move an overlay at RIGHT_PLACE to the next of the found one,
             and link it into the right place.  */
!         if (!right_pair)
            {
!             found->next = bp->overlays_before;
              bp->overlays_before = found;
            }
          else
            {
!             found->next = right_pair->next;
!             right_pair->next = found;
            }
        }
        else if (end == prev)
        {
          parent = tail;
!         tail = tail->next;
        }
        else                    /* No more disordered overlay. */
        break;
***************
*** 3543,3555 ****
    XOVERLAY (overlay)->start = beg;
    XOVERLAY (overlay)->end = end;
    XOVERLAY (overlay)->plist = Qnil;
  
    /* Put the new overlay on the wrong list.  */
    end = OVERLAY_END (overlay);
    if (OVERLAY_POSITION (end) < b->overlay_center)
!     b->overlays_after = Fcons (overlay, b->overlays_after);
    else
!     b->overlays_before = Fcons (overlay, b->overlays_before);
  
    /* This puts it in the right list, and in the right order.  */
    recenter_overlay_lists (b, b->overlay_center);
--- 3536,3557 ----
    XOVERLAY (overlay)->start = beg;
    XOVERLAY (overlay)->end = end;
    XOVERLAY (overlay)->plist = Qnil;
+   XOVERLAY (overlay)->next = NULL;
  
    /* Put the new overlay on the wrong list.  */
    end = OVERLAY_END (overlay);
    if (OVERLAY_POSITION (end) < b->overlay_center)
!     {
!       if (b->overlays_after)
!       XOVERLAY (overlay)->next = b->overlays_after;
!       b->overlays_after = XOVERLAY (overlay);
!     }
    else
!     {
!       if (b->overlays_before)
!       XOVERLAY (overlay)->next = b->overlays_before;
!       b->overlays_before = XOVERLAY (overlay);
!     }
  
    /* This puts it in the right list, and in the right order.  */
    recenter_overlay_lists (b, b->overlay_center);
***************
*** 3590,3595 ****
--- 3592,3615 ----
  
  Lisp_Object Fdelete_overlay ();
  
+ static struct Lisp_Overlay *
+ unchain_overlay (list, overlay)
+      struct Lisp_Overlay *list, *overlay;
+ {
+   struct Lisp_Overlay *tmp, *prev;
+   for (tmp = list, prev = NULL; tmp; prev = tmp, tmp = tmp->next)
+     if (tmp == overlay)
+       {
+       if (prev)
+         prev->next = tmp->next;
+       else
+         list = tmp->next;
+       overlay->next = NULL;
+       break;
+       }
+   return list;
+ }
+ 
  DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0,
         doc: /* Set the endpoints of OVERLAY to BEG and END in BUFFER.
  If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now.
***************
*** 3674,3681 ****
  
    if (!NILP (obuffer))
      {
!       ob->overlays_before = Fdelq (overlay, ob->overlays_before);
!       ob->overlays_after  = Fdelq (overlay, ob->overlays_after);
      }
  
    Fset_marker (OVERLAY_START (overlay), beg, buffer);
--- 3694,3704 ----
  
    if (!NILP (obuffer))
      {
!       ob->overlays_before
!       = unchain_overlay (ob->overlays_before, XOVERLAY (overlay));
!       ob->overlays_after
!       = unchain_overlay (ob->overlays_after, XOVERLAY (overlay));
!       eassert (XOVERLAY (overlay)->next == NULL);
      }
  
    Fset_marker (OVERLAY_START (overlay), beg, buffer);
***************
*** 3684,3692 ****
    /* Put the overlay on the wrong list.  */
    end = OVERLAY_END (overlay);
    if (OVERLAY_POSITION (end) < b->overlay_center)
!     b->overlays_after = Fcons (overlay, b->overlays_after);
    else
!     b->overlays_before = Fcons (overlay, b->overlays_before);
  
    /* This puts it in the right list, and in the right order.  */
    recenter_overlay_lists (b, b->overlay_center);
--- 3707,3723 ----
    /* Put the overlay on the wrong list.  */
    end = OVERLAY_END (overlay);
    if (OVERLAY_POSITION (end) < b->overlay_center)
!     {
!       if (b->overlays_after)
!       XOVERLAY (overlay)->next = b->overlays_after;
!     b->overlays_after = XOVERLAY (overlay);
!     }
    else
!     {
!       if (b->overlays_before)
!       XOVERLAY (overlay)->next = b->overlays_before;
!     b->overlays_before = XOVERLAY (overlay);
!     }
  
    /* This puts it in the right list, and in the right order.  */
    recenter_overlay_lists (b, b->overlay_center);
***************
*** 3712,3719 ****
    b = XBUFFER (buffer);
    specbind (Qinhibit_quit, Qt);
  
!   b->overlays_before = Fdelq (overlay, b->overlays_before);
!   b->overlays_after = Fdelq (overlay, b->overlays_after);
    modify_overlay (b,
                  marker_position (OVERLAY_START (overlay)),
                  marker_position (OVERLAY_END   (overlay)));
--- 3743,3751 ----
    b = XBUFFER (buffer);
    specbind (Qinhibit_quit, Qt);
  
!   b->overlays_before = unchain_overlay (b->overlays_before,XOVERLAY 
(overlay));
!   b->overlays_after  = unchain_overlay (b->overlays_after, XOVERLAY 
(overlay));
!   eassert (XOVERLAY (overlay)->next == NULL);
    modify_overlay (b,
                  marker_position (OVERLAY_START (overlay)),
                  marker_position (OVERLAY_END   (overlay)));
***************
*** 3921,3935 ****
  However, the overlays you get are the real objects that the buffer uses.  */)
       ()
  {
!   Lisp_Object before, after;
!   before = current_buffer->overlays_before;
!   if (CONSP (before))
!     before = Fcopy_sequence (before);
!   after = current_buffer->overlays_after;
!   if (CONSP (after))
!     after = Fcopy_sequence (after);
! 
!   return Fcons (before, after);
  }
  
  DEFUN ("overlay-recenter", Foverlay_recenter, Soverlay_recenter, 1, 1, 0,
--- 3953,3971 ----
  However, the overlays you get are the real objects that the buffer uses.  */)
       ()
  {
!   struct Lisp_Overlay *ol;
!   Lisp_Object before = Qnil, after = Qnil, tmp;
!   for (ol = current_buffer->overlays_before; ol; ol = ol->next)
!     {
!       XSETMISC (tmp, ol);
!       before = Fcons (tmp, before);
!     }
!   for (ol = current_buffer->overlays_after; ol; ol = ol->next)
!     {
!       XSETMISC (tmp, ol);
!       after = Fcons (tmp, after);
!     }
!   return Fcons (Fnreverse (before), Fnreverse (after));
  }
  
  DEFUN ("overlay-recenter", Foverlay_recenter, Soverlay_recenter, 1, 1, 0,
***************
*** 4029,4036 ****
             XVECTOR (last_overlay_modification_hooks)->contents,
             sizeof (Lisp_Object) * oldsize);
      }
!   XVECTOR 
(last_overlay_modification_hooks)->contents[last_overlay_modification_hooks_used++]
 = functionlist;
!   XVECTOR 
(last_overlay_modification_hooks)->contents[last_overlay_modification_hooks_used++]
 = overlay;
  }
  
  /* Run the modification-hooks of overlays that include
--- 4065,4072 ----
             XVECTOR (last_overlay_modification_hooks)->contents,
             sizeof (Lisp_Object) * oldsize);
      }
!   AREF (last_overlay_modification_hooks, 
last_overlay_modification_hooks_used++) = functionlist;
!   AREF (last_overlay_modification_hooks, 
last_overlay_modification_hooks_used++) = overlay;
  }
  
  /* Run the modification-hooks of overlays that include
***************
*** 4053,4079 ****
       int after;
       Lisp_Object arg1, arg2, arg3;
  {
!   Lisp_Object prop, overlay, tail;
    /* 1 if this change is an insertion.  */
    int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));
    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
  
    overlay = Qnil;
!   tail = Qnil;
  
    if (!after)
      {
        /* We are being called before a change.
         Scan the overlays to find the functions to call.  */
        last_overlay_modification_hooks_used = 0;
!       for (tail = current_buffer->overlays_before;
!          CONSP (tail);
!          tail = XCDR (tail))
        {
          int startpos, endpos;
          Lisp_Object ostart, oend;
  
!         overlay = XCAR (tail);
  
          ostart = OVERLAY_START (overlay);
          oend = OVERLAY_END (overlay);
--- 4089,4114 ----
       int after;
       Lisp_Object arg1, arg2, arg3;
  {
!   Lisp_Object prop, overlay;
!   struct Lisp_Overlay *tail;
    /* 1 if this change is an insertion.  */
    int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));
    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
  
    overlay = Qnil;
!   tail = NULL;
  
    if (!after)
      {
        /* We are being called before a change.
         Scan the overlays to find the functions to call.  */
        last_overlay_modification_hooks_used = 0;
!       for (tail = current_buffer->overlays_before; tail; tail = tail->next)
        {
          int startpos, endpos;
          Lisp_Object ostart, oend;
  
!         XSETMISC (overlay, tail);
  
          ostart = OVERLAY_START (overlay);
          oend = OVERLAY_END (overlay);
***************
*** 4104,4118 ****
                add_overlay_mod_hooklist (prop, overlay);
            }
        }
! 
!       for (tail = current_buffer->overlays_after;
!          CONSP (tail);
!          tail = XCDR (tail))
        {
          int startpos, endpos;
          Lisp_Object ostart, oend;
  
!         overlay = XCAR (tail);
  
          ostart = OVERLAY_START (overlay);
          oend = OVERLAY_END (overlay);
--- 4139,4151 ----
                add_overlay_mod_hooklist (prop, overlay);
            }
        }
!       
!       for (tail = current_buffer->overlays_after; tail; tail = tail->next)
        {
          int startpos, endpos;
          Lisp_Object ostart, oend;
  
!         XSETMISC (overlay, tail);
  
          ostart = OVERLAY_START (overlay);
          oend = OVERLAY_END (overlay);
***************
*** 4197,4211 ****
  evaporate_overlays (pos)
       EMACS_INT pos;
  {
!   Lisp_Object tail, overlay, hit_list;
  
    hit_list = Qnil;
    if (pos <= current_buffer->overlay_center)
!     for (tail = current_buffer->overlays_before; CONSP (tail);
!        tail = XCDR (tail))
        {
        int endpos;
!       overlay = XCAR (tail);
        endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
        if (endpos < pos)
          break;
--- 4230,4244 ----
  evaporate_overlays (pos)
       EMACS_INT pos;
  {
!   Lisp_Object overlay, hit_list;
!   struct Lisp_Overlay *tail;
  
    hit_list = Qnil;
    if (pos <= current_buffer->overlay_center)
!     for (tail = current_buffer->overlays_before; tail; tail = tail->next)
        {
        int endpos;
!       XSETMISC (overlay, tail);
        endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
        if (endpos < pos)
          break;
***************
*** 4214,4224 ****
          hit_list = Fcons (overlay, hit_list);
        }
    else
!     for (tail = current_buffer->overlays_after; CONSP (tail);
!        tail = XCDR (tail))
        {
        int startpos;
!       overlay = XCAR (tail);
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
        if (startpos > pos)
          break;
--- 4247,4256 ----
          hit_list = Fcons (overlay, hit_list);
        }
    else
!     for (tail = current_buffer->overlays_after; tail; tail = tail->next)
        {
        int startpos;
!       XSETMISC (overlay, tail);
        startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
        if (startpos > pos)
          break;
***************
*** 4858,4865 ****
    buffer_defaults.undo_list = Qnil;
    buffer_defaults.mark_active = Qnil;
    buffer_defaults.file_format = Qnil;
!   buffer_defaults.overlays_before = Qnil;
!   buffer_defaults.overlays_after = Qnil;
    buffer_defaults.overlay_center = BEG;
  
    XSETFASTINT (buffer_defaults.tab_width, 8);
--- 4890,4897 ----
    buffer_defaults.undo_list = Qnil;
    buffer_defaults.mark_active = Qnil;
    buffer_defaults.file_format = Qnil;
!   buffer_defaults.overlays_before = NULL;
!   buffer_defaults.overlays_after = NULL;
    buffer_defaults.overlay_center = BEG;
  
    XSETFASTINT (buffer_defaults.tab_width, 8);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]