From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: Should overlays evaporate by default? Date: 19 May 2005 04:24:39 -0400 Message-ID: References: <200505161459.j4GExamZ005296@brains.moreideas.ca> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1116495941 26262 80.91.229.2 (19 May 2005 09:45:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 19 May 2005 09:45:41 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 19 11:45:40 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DYhZ4-0004TK-P8 for ged-emacs-devel@m.gmane.org; Thu, 19 May 2005 11:43:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DYhbf-00066i-4r for ged-emacs-devel@m.gmane.org; Thu, 19 May 2005 05:46:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DYgZx-0000x0-0i for emacs-devel@gnu.org; Thu, 19 May 2005 04:40:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DYgYx-0000js-WE for emacs-devel@gnu.org; Thu, 19 May 2005 04:39:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DYgVG-0007TE-AB for emacs-devel@gnu.org; Thu, 19 May 2005 04:35:38 -0400 Original-Received: from [207.245.121.138] (helo=mail.agora-net.com) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_ARCFOUR_SHA:16) (Exim 4.34) id 1DYgSp-0002Yc-GS; Thu, 19 May 2005 04:33:07 -0400 Original-Received: from ttn by mail.agora-net.com with local (Exim 4.34) id 1DYgKd-0006j4-FE; Thu, 19 May 2005 04:24:39 -0400 Original-To: rms@gnu.org In-Reply-To: Original-Lines: 155 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:37341 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:37341 Richard Stallman 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");