From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: Strange problem with latest CVS Date: Thu, 08 Apr 2004 20:45:37 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <20040408.204537.177222368.jet@gyve.org> References: <20040407.194947.101661727.jet@gyve.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1081426378 31374 80.91.224.253 (8 Apr 2004 12:12:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Apr 2004 12:12:58 +0000 (UTC) Cc: romain@orebokech.com, matt@stchem.bham.ac.uk, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Apr 08 14:12:45 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BBYOj-0003VK-00 for ; Thu, 08 Apr 2004 14:12:45 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BBYOh-0003lW-00 for ; Thu, 08 Apr 2004 14:12:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BBYNC-0007GX-3K for emacs-devel@quimby.gnus.org; Thu, 08 Apr 2004 08:11:10 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BBY28-0003L6-Vg for emacs-devel@gnu.org; Thu, 08 Apr 2004 07:49:24 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BBY0T-0002oO-JP for emacs-devel@gnu.org; Thu, 08 Apr 2004 07:48:12 -0400 Original-Received: from [210.130.136.40] (helo=r-maa.spacetown.ne.jp) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BBXyj-0002CR-M2; Thu, 08 Apr 2004 07:45:53 -0400 Original-Received: from localhost ([219.120.63.249]) by r-maa.spacetown.ne.jp (8.11.6) with ESMTP id i38Bjnb12472; Thu, 8 Apr 2004 20:45:49 +0900 (JST) Original-To: rms@gnu.org In-Reply-To: X-Mailer: Mew version 4.0.62 on Emacs 21.3.50 / Mule 5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:21358 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21358 > How do you think make evaporate overlay's property t by default(when make-overlay)? > > That would break many programs. It is the wrong solution. > > I think the right fix is in fix_start_end_in_overlays. When an > insertion occurs next to an overlay whose beginning-marker is the > advancing kind and whose end-marker is not, the overlay should stay > empty. I've tried. I have done in two things in the attached patch. 1) I could still find the situation that Emacs returned an overlay whose start is greater than its end. I have fixed in the patch. 2) As you wrote, I made overlays empty in fix_start_end_in_overlays. The biggest question is that whether I should use overlay-start or overlay-end to make an overlay empty. I'm using following code in the patch. // for overlay_before int pivot = (startpos >= start)? endpos: startpos; // for overlay_after int pivot = (endpos < end)? startpos: endpos; Fset_marker (OVERLAY_START (overlay), make_number (pivot), Qnil); Fset_marker (OVERLAY_END (overlay), make_number (pivot), Qnil); Masatake YAMATO 2004-04-08 Masatake YAMATO * buffer.c (fix_start_end_in_overlays): Normalize the order of start and end in overlays before comparing the edited range and overlay. Introduce `make_empty' local variable. Make it true if an overlay is upside-down. Make overlay empty if it is upside-down. cvs diff: warning: unrecognized response `access control disabled, clients can connect from any host' from cvs server Index: src/buffer.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/buffer.c,v retrieving revision 1.446 diff -u -r1.446 buffer.c *** src/buffer.c 25 Mar 2004 18:05:29 -0000 1.446 --- src/buffer.c 8 Apr 2004 10:53:03 -0000 *************** *** 3290,3297 **** endpoint in this range will need to be unlinked from the overlay list and reinserted in its proper place. Such an overlay might even have negative size at this point. ! If so, we'll reverse the endpoints. Can you think of anything ! better to do in this situation? */ void fix_start_end_in_overlays (start, end) register int start, end; --- 3290,3296 ---- endpoint in this range will need to be unlinked from the overlay list and reinserted in its proper place. Such an overlay might even have negative size at this point. ! If so, we'll make the overlay empty. */ void fix_start_end_in_overlays (start, end) register int start, end; *************** *** 3308,3313 **** --- 3307,3313 ---- struct Lisp_Overlay *tail, *parent; int startpos, endpos; + int make_empty; /* This algorithm shifts links around instead of consing and GCing. The loop invariant is that before_list (resp. after_list) is a well-formed list except that its last element, the CDR of beforep *************** *** 3318,3339 **** for (parent = NULL, tail = current_buffer->overlays_before; tail;) { XSETMISC (overlay, tail); endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); if (endpos < start) break; ! startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); if (endpos < end || (startpos >= start && startpos < end)) { ! /* If the overlay is backwards, fix that now. */ ! if (startpos > endpos) { ! int tem; ! Fset_marker (OVERLAY_START (overlay), make_number (endpos), Qnil); ! Fset_marker (OVERLAY_END (overlay), make_number (startpos), Qnil); - tem = startpos; startpos = endpos; endpos = tem; } /* Add it to the end of the wrong list. Later on, recenter_overlay_lists will move it to the right place. */ --- 3318,3354 ---- for (parent = NULL, tail = current_buffer->overlays_before; tail;) { XSETMISC (overlay, tail); + + /* Normalize the order of startpos and endpos. */ endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); + startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); + if (endpos < startpos) + { + int tem; + make_empty = 1; + tem = startpos; + startpos = endpos; + endpos = tem; + } + else + make_empty = 0; + + /* The order of startpos and endpos is normalized. + So we can use endpos to be comapred with start. */ if (endpos < start) break; ! if (endpos < end || (startpos >= start && startpos < end)) { ! /* If the overlay is backwards, make it empty. */ ! if (make_empty) { ! int pivot = (startpos >= start)? endpos: startpos; ! Fset_marker (OVERLAY_START (overlay), make_number (pivot), Qnil); ! Fset_marker (OVERLAY_END (overlay), make_number (pivot), Qnil); } /* Add it to the end of the wrong list. Later on, recenter_overlay_lists will move it to the right place. */ *************** *** 3362,3385 **** 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; ! endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); if (startpos >= start || (endpos >= start && endpos < end)) { ! if (startpos > endpos) { ! int tem; ! Fset_marker (OVERLAY_START (overlay), make_number (endpos), Qnil); ! Fset_marker (OVERLAY_END (overlay), make_number (startpos), Qnil); - tem = startpos; startpos = endpos; endpos = tem; } if (endpos < current_buffer->overlay_center) { --- 3377,3417 ---- else parent = tail, tail = parent->next; } + + make_empty = 0; for (parent = NULL, tail = current_buffer->overlays_after; tail;) { XSETMISC (overlay, tail); startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); + endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); + + /* Normalize the order of startpos and endpos. */ + if (endpos < startpos) + { + int tem; + make_empty = 1; + tem = startpos; + startpos = endpos; + endpos = tem; + } + else + make_empty = 0; + + /* The order of startpos and endpos is normalized. + So we can use endpos to be comapred with start. */ if (startpos >= end) break; ! if (startpos >= start || (endpos >= start && endpos < end)) { ! if (make_empty) { ! int pivot = (endpos < end)? startpos: endpos; ! Fset_marker (OVERLAY_START (overlay), make_number (pivot), Qnil); ! Fset_marker (OVERLAY_END (overlay), make_number (pivot), Qnil); } if (endpos < current_buffer->overlay_center) {