all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Masatake YAMATO <jet@gyve.org>
Cc: romain@orebokech.com, matt@stchem.bham.ac.uk, emacs-devel@gnu.org
Subject: Re: Strange problem with latest CVS
Date: Thu, 08 Apr 2004 20:45:37 +0900 (JST)	[thread overview]
Message-ID: <20040408.204537.177222368.jet@gyve.org> (raw)
In-Reply-To: <E1BBO1E-0000dN-8P@fencepost.gnu.org>

>     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  <jet@gyve.org>

	* 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)
  	    {

  parent reply	other threads:[~2004-04-08 11:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <jet@gyve.org>
2004-04-07 10:49 ` Strange problem with latest CVS Masatake YAMATO
2004-04-07 20:03   ` peta
2004-04-08  3:27     ` Richard Stallman
2004-04-08  4:02       ` Masatake YAMATO
2004-04-09 22:45         ` Richard Stallman
2004-04-12  4:11           ` Masatake YAMATO
2004-04-13 17:45             ` Richard Stallman
2004-04-13 18:33               ` David Kastrup
2004-04-14  3:13                 ` Masatake YAMATO
2004-04-14 22:53                   ` Richard Stallman
2004-04-14 22:54                 ` Richard Stallman
2004-04-19  8:27                   ` Masatake YAMATO
2004-04-19 18:20                     ` Richard Stallman
2004-04-20  4:40                       ` Masatake YAMATO
2004-04-20 20:47                         ` Richard Stallman
2004-04-21 13:20                           ` Masatake YAMATO
2004-04-08  1:07   ` Richard Stallman
2004-04-08  4:03     ` Masatake YAMATO
2004-04-08 11:45     ` Masatake YAMATO [this message]
2004-04-09 22:44       ` Richard Stallman
2004-04-10 17:56         ` Masatake YAMATO
2004-04-10 22:09           ` Kim F. Storm
2004-04-10 20:23             ` Masatake YAMATO
2004-03-31 15:48 Piet van Oostrum
2004-03-31 20:26 ` Matt Hodges
2004-04-02 10:16   ` Matt Hodges
2004-04-04 20:31     ` Romain Francoise

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040408.204537.177222368.jet@gyve.org \
    --to=jet@gyve.org \
    --cc=emacs-devel@gnu.org \
    --cc=matt@stchem.bham.ac.uk \
    --cc=romain@orebokech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.