/[emacs]/emacs/src/buffer.c
ViewVC logotype

Diff of /emacs/src/buffer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.429 by monnier, Tue Jul 8 21:47:55 2003 UTC revision 1.430 by monnier, Tue Jul 8 22:09:23 2003 UTC
# Line 4056  report_overlay_modification (start, end, Line 4056  report_overlay_modification (start, end,
4056    Lisp_Object prop, overlay, tail;    Lisp_Object prop, overlay, tail;
4057    /* 1 if this change is an insertion.  */    /* 1 if this change is an insertion.  */
4058    int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));    int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));
4059    int tail_copied;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;  
4060    
4061    overlay = Qnil;    overlay = Qnil;
4062    tail = Qnil;    tail = Qnil;
   GCPRO5 (overlay, tail, arg1, arg2, arg3);  
   
   if (after)  
     {  
       /* Call the functions recorded in last_overlay_modification_hooks  
          rather than scanning the overlays again.  
          First copy the vector contents, in case some of these hooks  
          do subsequent modification of the buffer.  */  
       int size = last_overlay_modification_hooks_used;  
       Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object));  
       int i;  
   
       bcopy (XVECTOR (last_overlay_modification_hooks)->contents,  
              copy, size * sizeof (Lisp_Object));  
       gcpro1.var = copy;  
       gcpro1.nvars = size;  
   
       for (i = 0; i < size;)  
         {  
           Lisp_Object prop, overlay;  
           prop = copy[i++];  
           overlay = copy[i++];  
           call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);  
         }  
       UNGCPRO;  
       return;  
     }  
   
   /* We are being called before a change.  
      Scan the overlays to find the functions to call.  */  
   last_overlay_modification_hooks_used = 0;  
   tail_copied = 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);  
       endpos = OVERLAY_POSITION (oend);  
       if (XFASTINT (start) > endpos)  
         break;  
       startpos = OVERLAY_POSITION (ostart);  
       if (insertion && (XFASTINT (start) == startpos  
                         || XFASTINT (end) == startpos))  
         {  
           prop = Foverlay_get (overlay, Qinsert_in_front_hooks);  
           if (!NILP (prop))  
             {  
               /* Copy TAIL in case the hook recenters the overlay lists.  */  
               if (!tail_copied)  
                 tail = Fcopy_sequence (tail);  
               tail_copied = 1;  
               call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);  
             }  
         }  
       if (insertion && (XFASTINT (start) == endpos  
                         || XFASTINT (end) == endpos))  
         {  
           prop = Foverlay_get (overlay, Qinsert_behind_hooks);  
           if (!NILP (prop))  
             {  
               if (!tail_copied)  
                 tail = Fcopy_sequence (tail);  
               tail_copied = 1;  
               call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);  
             }  
         }  
       /* Test for intersecting intervals.  This does the right thing  
          for both insertion and deletion.  */  
       if (XFASTINT (end) > startpos && XFASTINT (start) < endpos)  
         {  
           prop = Foverlay_get (overlay, Qmodification_hooks);  
           if (!NILP (prop))  
             {  
               if (!tail_copied)  
                 tail = Fcopy_sequence (tail);  
               tail_copied = 1;  
               call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);  
             }  
         }  
     }  
4063    
4064    tail_copied = 0;    if (!after)
   for (tail = current_buffer->overlays_after;  
        CONSP (tail);  
        tail = XCDR (tail))  
4065      {      {
4066        int startpos, endpos;        /* We are being called before a change.
4067        Lisp_Object ostart, oend;           Scan the overlays to find the functions to call.  */
4068          last_overlay_modification_hooks_used = 0;
4069        overlay = XCAR (tail);        for (tail = current_buffer->overlays_before;
4070               CONSP (tail);
4071        ostart = OVERLAY_START (overlay);             tail = XCDR (tail))
4072        oend = OVERLAY_END (overlay);          {
4073        startpos = OVERLAY_POSITION (ostart);            int startpos, endpos;
4074        endpos = OVERLAY_POSITION (oend);            Lisp_Object ostart, oend;
4075        if (XFASTINT (end) < startpos)  
4076          break;            overlay = XCAR (tail);
4077        if (insertion && (XFASTINT (start) == startpos  
4078                          || XFASTINT (end) == startpos))            ostart = OVERLAY_START (overlay);
4079          {            oend = OVERLAY_END (overlay);
4080            prop = Foverlay_get (overlay, Qinsert_in_front_hooks);            endpos = OVERLAY_POSITION (oend);
4081            if (!NILP (prop))            if (XFASTINT (start) > endpos)
4082              {              break;
4083                if (!tail_copied)            startpos = OVERLAY_POSITION (ostart);
4084                  tail = Fcopy_sequence (tail);            if (insertion && (XFASTINT (start) == startpos
4085                tail_copied = 1;                              || XFASTINT (end) == startpos))
4086                call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);              {
4087              }                prop = Foverlay_get (overlay, Qinsert_in_front_hooks);
4088          }                if (!NILP (prop))
4089        if (insertion && (XFASTINT (start) == endpos                  add_overlay_mod_hooklist (prop, overlay);
4090                          || XFASTINT (end) == endpos))              }
4091          {            if (insertion && (XFASTINT (start) == endpos
4092            prop = Foverlay_get (overlay, Qinsert_behind_hooks);                              || XFASTINT (end) == endpos))
4093            if (!NILP (prop))              {
4094              {                prop = Foverlay_get (overlay, Qinsert_behind_hooks);
4095                if (!tail_copied)                if (!NILP (prop))
4096                  tail = Fcopy_sequence (tail);                  add_overlay_mod_hooklist (prop, overlay);
4097                tail_copied = 1;              }
4098                call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);            /* Test for intersecting intervals.  This does the right thing
4099              }               for both insertion and deletion.  */
4100          }            if (XFASTINT (end) > startpos && XFASTINT (start) < endpos)
4101        /* Test for intersecting intervals.  This does the right thing              {
4102           for both insertion and deletion.  */                prop = Foverlay_get (overlay, Qmodification_hooks);
4103        if (XFASTINT (end) > startpos && XFASTINT (start) < endpos)                if (!NILP (prop))
4104          {                  add_overlay_mod_hooklist (prop, overlay);
4105            prop = Foverlay_get (overlay, Qmodification_hooks);              }
4106            if (!NILP (prop))          }
4107              {  
4108                if (!tail_copied)        for (tail = current_buffer->overlays_after;
4109                  tail = Fcopy_sequence (tail);             CONSP (tail);
4110                tail_copied = 1;             tail = XCDR (tail))
4111                call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);          {
4112              int startpos, endpos;
4113              Lisp_Object ostart, oend;
4114    
4115              overlay = XCAR (tail);
4116    
4117              ostart = OVERLAY_START (overlay);
4118              oend = OVERLAY_END (overlay);
4119              startpos = OVERLAY_POSITION (ostart);
4120              endpos = OVERLAY_POSITION (oend);
4121              if (XFASTINT (end) < startpos)
4122                break;
4123              if (insertion && (XFASTINT (start) == startpos
4124                                || XFASTINT (end) == startpos))
4125                {
4126                  prop = Foverlay_get (overlay, Qinsert_in_front_hooks);
4127                  if (!NILP (prop))
4128                    add_overlay_mod_hooklist (prop, overlay);
4129                }
4130              if (insertion && (XFASTINT (start) == endpos
4131                                || XFASTINT (end) == endpos))
4132                {
4133                  prop = Foverlay_get (overlay, Qinsert_behind_hooks);
4134                  if (!NILP (prop))
4135                    add_overlay_mod_hooklist (prop, overlay);
4136                }
4137              /* Test for intersecting intervals.  This does the right thing
4138                 for both insertion and deletion.  */
4139              if (XFASTINT (end) > startpos && XFASTINT (start) < endpos)
4140                {
4141                  prop = Foverlay_get (overlay, Qmodification_hooks);
4142                  if (!NILP (prop))
4143                    add_overlay_mod_hooklist (prop, overlay);
4144              }              }
4145          }          }
4146      }      }
4147    
4148      GCPRO4 (overlay, arg1, arg2, arg3);
4149      {
4150        /* Call the functions recorded in last_overlay_modification_hooks.
4151           First copy the vector contents, in case some of these hooks
4152           do subsequent modification of the buffer.  */
4153        int size = last_overlay_modification_hooks_used;
4154        Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object));
4155        int i;
4156    
4157        bcopy (XVECTOR (last_overlay_modification_hooks)->contents,
4158               copy, size * sizeof (Lisp_Object));
4159        gcpro1.var = copy;
4160        gcpro1.nvars = size;
4161    
4162        for (i = 0; i < size;)
4163          {
4164            Lisp_Object prop, overlay;
4165            prop = copy[i++];
4166            overlay = copy[i++];
4167            call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4168          }
4169      }
4170    UNGCPRO;    UNGCPRO;
4171  }  }
4172    
# Line 4215  call_overlay_mod_hooks (list, overlay, a Line 4179  call_overlay_mod_hooks (list, overlay, a
4179    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
4180    
4181    GCPRO4 (list, arg1, arg2, arg3);    GCPRO4 (list, arg1, arg2, arg3);
   if (! after)  
     add_overlay_mod_hooklist (list, overlay);  
4182    
4183    while (CONSP (list))    while (CONSP (list))
4184      {      {

Legend:
Removed from v.1.429  
changed lines
  Added in v.1.430

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26