emacs-devel
[Top][All Lists]
Advanced

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

Re: Should overlays evaporate by default?


From: Thien-Thi Nguyen
Subject: Re: Should overlays evaporate by default?
Date: 19 May 2005 04:24:39 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Richard Stallman <address@hidden> writes:

> The goal now is to *find* possible bugs.
> The patch should set the property to something unusual (maybe
> `never-set') by default.  When such an overlay becomes empty, there
> should be some sort of warning.  That way, people will find code
> that perhaps ought to set the evaporate property to something
> explicitly.

ok, below is a patch to buffer.c that does this, more or less.  the
(%d,%d) is perhaps redundant, but since we're in the checking mood...

thi

___________________________________________________________
*** buffer.c    4 May 2005 22:10:14 -0000       1.479
--- buffer.c    19 May 2005 08:14:13 -0000
***************
*** 178,183 ****
--- 178,189 ----
  Lisp_Object Qinsert_in_front_hooks;
  Lisp_Object Qinsert_behind_hooks;
  
+ #define OVERLAY_EVAPORATE_TESTING
+ #ifdef OVERLAY_EVAPORATE_TESTING
+ Lisp_Object Qnever_set;
+ static Lisp_Object evaporate_overlay P_ ((Lisp_Object));
+ #endif
+ 
  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 *));
***************
*** 3602,3607 ****
--- 3608,3617 ----
    XOVERLAY (overlay)->plist = Qnil;
    XOVERLAY (overlay)->next = NULL;
  
+ #ifdef OVERLAY_EVAPORATE_TESTING
+   Foverlay_put (overlay, Qevaporate, Qnever_set);
+ #endif
+ 
    /* Put the new overlay on the wrong list.  */
    end = OVERLAY_END (overlay);
    if (OVERLAY_POSITION (end) < b->overlay_center)
***************
*** 3656,3661 ****
--- 3666,3689 ----
  
  Lisp_Object Fdelete_overlay ();
  
+ #ifdef OVERLAY_EVAPORATE_TESTING
+ static Lisp_Object
+ evaporate_overlay (overlay)
+      Lisp_Object overlay;
+ {
+   if (EQ (Qnever_set, Foverlay_get (overlay, Qevaporate)))
+     {
+       char msg[256];
+       sprintf (msg, "WARNING: overlay (%d,%d) evaporating unexpectedly",
+                OVERLAY_POSITION (OVERLAY_START (overlay)),
+                OVERLAY_POSITION (OVERLAY_END (overlay)));
+       message (msg);
+     }
+ 
+   return Fdelete_overlay (overlay);
+ }
+ #endif
+ 
  static struct Lisp_Overlay *
  unchain_overlay (list, overlay)
       struct Lisp_Overlay *list, *overlay;
***************
*** 3704,3710 ****
    CHECK_NUMBER_COERCE_MARKER (end);
  
    if (XINT (beg) == XINT (end) && ! NILP (Foverlay_get (overlay, Qevaporate)))
!     return Fdelete_overlay (overlay);
  
    if (XINT (beg) > XINT (end))
      {
--- 3732,3744 ----
    CHECK_NUMBER_COERCE_MARKER (end);
  
    if (XINT (beg) == XINT (end) && ! NILP (Foverlay_get (overlay, Qevaporate)))
!     return
! #ifndef OVERLAY_EVAPORATE_TESTING
!       Fdelete_overlay
! #else
!       evaporate_overlay
! #endif
!       (overlay);
  
    if (XINT (beg) > XINT (end))
      {
***************
*** 4088,4094 ****
        if (EQ (prop, Qevaporate) && ! NILP (value)
          && (OVERLAY_POSITION (OVERLAY_START (overlay))
              == OVERLAY_POSITION (OVERLAY_END (overlay))))
!       Fdelete_overlay (overlay);
      }
    return value;
  }
--- 4122,4134 ----
        if (EQ (prop, Qevaporate) && ! NILP (value)
          && (OVERLAY_POSITION (OVERLAY_START (overlay))
              == OVERLAY_POSITION (OVERLAY_END (overlay))))
! #ifndef OVERLAY_EVAPORATE_TESTING
!       Fdelete_overlay
! #else
!         evaporate_overlay
! #endif
!           (overlay);
! 
      }
    return value;
  }
***************
*** 4330,4336 ****
          hit_list = Fcons (overlay, hit_list);
        }
    for (; CONSP (hit_list); hit_list = XCDR (hit_list))
!     Fdelete_overlay (XCAR (hit_list));
  }
  
  /* Somebody has tried to store a value with an unacceptable type
--- 4370,4381 ----
          hit_list = Fcons (overlay, hit_list);
        }
    for (; CONSP (hit_list); hit_list = XCDR (hit_list))
! #ifndef OVERLAY_EVAPORATE_TESTING
!     Fdelete_overlay
! #else
!     evaporate_overlay
! #endif
!       (XCAR (hit_list));
  }
  
  /* Somebody has tried to store a value with an unacceptable type
***************
*** 5207,5212 ****
--- 5252,5261 ----
    staticpro (&Qoverlayp);
    Qevaporate = intern ("evaporate");
    staticpro (&Qevaporate);
+ #ifdef OVERLAY_EVAPORATE_TESTING
+   Qnever_set = intern ("never-set");
+   staticpro (&Qnever_set);
+ #endif
    Qmodification_hooks = intern ("modification-hooks");
    staticpro (&Qmodification_hooks);
    Qinsert_in_front_hooks = intern ("insert-in-front-hooks");






reply via email to

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