unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9642: move-overlay creates an empty overlay with the evaporate property
@ 2011-09-30 22:55 Paul Eggert
  2011-10-01  3:09 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Paul Eggert @ 2011-09-30 22:55 UTC (permalink / raw)
  To: 9642

Package: Emacs
Version: 24.0.90
Tags: patch

In a nonempty buffer, the following:

  (let ((o (make-overlay 1 2)))
    (overlay-put o 'evaporate t)
    (move-overlay o 0 1))

returns an empty overlay that has the evaporate property.
But this is not supposed to happen: when an overlay with that
property becomes empty, it's supposed to be deleted.

Here's a patch that I'd like to install after a bit more testing.


* buffer.c (Fmove_overlay): Delete an evaporating overlay
if it becomes empty after its bounds are adjusted to fit within
its buffer.  Without this fix, in a nonempty buffer (let ((o
(make-overlay 1 2))) (overlay-put o 'evaporate t) (move-overlay o 0 1))
yields an empty overlay that has the evaporate property, which is
not supposed to happen.

=== modified file 'src/buffer.c'
--- src/buffer.c	2011-09-30 20:22:01 +0000
+++ src/buffer.c	2011-09-30 22:29:34 +0000
@@ -3673,6 +3673,7 @@
   struct buffer *b, *ob;
   Lisp_Object obuffer;
   int count = SPECPDL_INDEX ();
+  ptrdiff_t n_beg, n_end;

   CHECK_OVERLAY (overlay);
   if (NILP (buffer))
@@ -3691,15 +3692,20 @@
   CHECK_NUMBER_COERCE_MARKER (beg);
   CHECK_NUMBER_COERCE_MARKER (end);

-  if (XINT (beg) == XINT (end) && ! NILP (Foverlay_get (overlay, Qevaporate)))
+  if (XINT (beg) > XINT (end))
+    {
+      Lisp_Object temp;
+      temp = beg; beg = end; end = temp;
+    }
+
+  Fset_marker (OVERLAY_START (overlay), beg, buffer);
+  Fset_marker (OVERLAY_END (overlay), end, buffer);
+  n_beg = marker_position (OVERLAY_START (overlay));
+  n_end = marker_position (OVERLAY_END (overlay));
+
+  if (n_beg == n_end && ! NILP (Foverlay_get (overlay, Qevaporate)))
     return Fdelete_overlay (overlay);

-  if (XINT (beg) > XINT (end))
-    {
-      Lisp_Object temp;
-      temp = beg; beg = end; end = temp;
-    }
-
   specbind (Qinhibit_quit, Qt);

   obuffer = Fmarker_buffer (OVERLAY_START (overlay));
@@ -3722,7 +3728,7 @@
 	}

       /* Redisplay where the overlay is going to be.  */
-      modify_overlay (b, XINT (beg), XINT (end));
+      modify_overlay (b, n_beg, n_end);
     }
   else
     /* Redisplay the area the overlay has just left, or just enclosed.  */
@@ -3732,16 +3738,12 @@
       o_beg = OVERLAY_POSITION (OVERLAY_START (overlay));
       o_end = OVERLAY_POSITION (OVERLAY_END (overlay));

-      if (o_beg == XINT (beg))
-	modify_overlay (b, o_end, XINT (end));
-      else if (o_end == XINT (end))
-	modify_overlay (b, o_beg, XINT (beg));
+      if (o_beg == n_beg)
+	modify_overlay (b, o_end, n_end);
+      else if (o_end == n_end)
+	modify_overlay (b, o_beg, n_beg);
       else
-	{
-	  if (XINT (beg) < o_beg) o_beg = XINT (beg);
-	  if (XINT (end) > o_end) o_end = XINT (end);
-	  modify_overlay (b, o_beg, o_end);
-	}
+	modify_overlay (b, min (o_beg, n_beg), max (o_end, n_end));
     }

   if (!NILP (obuffer))
@@ -3753,12 +3755,8 @@
       eassert (XOVERLAY (overlay)->next == NULL);
     }

-  Fset_marker (OVERLAY_START (overlay), beg, buffer);
-  Fset_marker (OVERLAY_END   (overlay), end, buffer);
-
   /* Put the overlay on the wrong list.  */
-  end = OVERLAY_END (overlay);
-  if (OVERLAY_POSITION (end) < b->overlay_center)
+  if (n_end < b->overlay_center)
     {
       XOVERLAY (overlay)->next = b->overlays_after;
       b->overlays_after = XOVERLAY (overlay);





^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2012-05-29 16:16 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-30 22:55 bug#9642: move-overlay creates an empty overlay with the evaporate property Paul Eggert
2011-10-01  3:09 ` Stefan Monnier
2011-10-01  4:01   ` Stefan Monnier
2011-10-01  7:33     ` Paul Eggert
2011-10-01  8:22       ` Eli Zaretskii
2011-10-02  5:38         ` Paul Eggert
2011-10-02  6:56           ` Eli Zaretskii
2011-10-03  1:09             ` Paul Eggert
2011-10-03  3:56               ` Eli Zaretskii
2011-10-03  4:21                 ` Paul Eggert
2011-10-03  3:15   ` Stefan Monnier
2011-10-03  5:36     ` Eli Zaretskii
2011-10-03 13:21       ` Stefan Monnier
2012-04-23 22:48 ` Paul Eggert
     [not found] ` <handler.9642.D9642.133522137028631.notifdone@debbugs.gnu.org>
2012-04-26 15:30   ` bug#9642: closed (Re: bug#9642: move-overlay creates an empty overlay with the evaporate property) Tassilo Horn
2012-04-27 16:27     ` Tassilo Horn
2012-04-27 18:38       ` Tassilo Horn
2012-04-28  7:34         ` Eli Zaretskii
2012-04-28 13:17           ` Stefan Monnier
2012-04-28 22:20         ` Paul Eggert
2012-04-29  7:57           ` Tassilo Horn
2012-04-29 19:41             ` Paul Eggert
2012-04-30  9:40             ` Troels Nielsen
2012-05-14  5:46               ` Stefan Monnier
2012-05-27 22:09                 ` Troels Nielsen
2012-05-29 16:16                   ` Paul Eggert

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).