aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-09-30 16:06:51 -0700
committerPaul Eggert2011-09-30 16:06:51 -0700
commit79cce3f2364019ca04f34857e01c76c4e7b39004 (patch)
treeb805e27689d167e996c2fa186e3fb10c554010ef /src
parent3f588b57fc3f804104f60e102a04acfd104c4752 (diff)
downloademacs-79cce3f2364019ca04f34857e01c76c4e7b39004.tar.gz
emacs-79cce3f2364019ca04f34857e01c76c4e7b39004.zip
* 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. (Bug#9642)
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/buffer.c33
2 files changed, 20 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 790ae712476..bd20439ccc7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -43,6 +43,12 @@
43 (Foverlays_at, Fnext_overlay_change, Fprevious_overlay_change): 43 (Foverlays_at, Fnext_overlay_change, Fprevious_overlay_change):
44 Omit pointer cast, which isn't needed anyway, and doesn't work 44 Omit pointer cast, which isn't needed anyway, and doesn't work
45 after the EMACS_INT -> ptrdiff_t change. 45 after the EMACS_INT -> ptrdiff_t change.
46 (Fmove_overlay): Delete an evaporating overlay
47 if it becomes empty after its bounds are adjusted to fit within
48 its buffer. Without this fix, in a nonempty buffer (let ((o
49 (make-overlay 1 2))) (overlay-put o 'evaporate t) (move-overlay o 0 1))
50 yields an empty overlay that has the evaporate property, which is
51 not supposed to happen. (Bug#9642)
46 * buffer.h: Adjust decls to match defn changes elsewhere. 52 * buffer.h: Adjust decls to match defn changes elsewhere.
47 (struct buffer_text, struct buffer): 53 (struct buffer_text, struct buffer):
48 Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough. 54 Use ptrdiff_t, not EMACS_INT, where ptrdiff_t is wide enough.
diff --git a/src/buffer.c b/src/buffer.c
index 2c7b426be84..3f278eb807b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3672,6 +3672,7 @@ buffer. */)
3672 struct buffer *b, *ob; 3672 struct buffer *b, *ob;
3673 Lisp_Object obuffer; 3673 Lisp_Object obuffer;
3674 ptrdiff_t count = SPECPDL_INDEX (); 3674 ptrdiff_t count = SPECPDL_INDEX ();
3675 ptrdiff_t n_beg, n_end;
3675 3676
3676 CHECK_OVERLAY (overlay); 3677 CHECK_OVERLAY (overlay);
3677 if (NILP (buffer)) 3678 if (NILP (buffer))
@@ -3696,16 +3697,18 @@ buffer. */)
3696 temp = beg; beg = end; end = temp; 3697 temp = beg; beg = end; end = temp;
3697 } 3698 }
3698 3699
3699 b = XBUFFER (buffer); 3700 Fset_marker (OVERLAY_START (overlay), beg, buffer);
3700 if (! (BUF_BEGV (b) <= XINT (beg) && XINT (end) <= BUF_ZV (b))) 3701 Fset_marker (OVERLAY_END (overlay), end, buffer);
3701 args_out_of_range (beg, end); 3702 n_beg = marker_position (OVERLAY_START (overlay));
3703 n_end = marker_position (OVERLAY_END (overlay));
3702 3704
3703 if (XINT (beg) == XINT (end) && ! NILP (Foverlay_get (overlay, Qevaporate))) 3705 if (n_beg == n_end && ! NILP (Foverlay_get (overlay, Qevaporate)))
3704 return Fdelete_overlay (overlay); 3706 return Fdelete_overlay (overlay);
3705 3707
3706 specbind (Qinhibit_quit, Qt); 3708 specbind (Qinhibit_quit, Qt);
3707 3709
3708 obuffer = Fmarker_buffer (OVERLAY_START (overlay)); 3710 obuffer = Fmarker_buffer (OVERLAY_START (overlay));
3711 b = XBUFFER (buffer);
3709 ob = BUFFERP (obuffer) ? XBUFFER (obuffer) : (struct buffer *) 0; 3712 ob = BUFFERP (obuffer) ? XBUFFER (obuffer) : (struct buffer *) 0;
3710 3713
3711 /* If the overlay has changed buffers, do a thorough redisplay. */ 3714 /* If the overlay has changed buffers, do a thorough redisplay. */
@@ -3724,7 +3727,7 @@ buffer. */)
3724 } 3727 }
3725 3728
3726 /* Redisplay where the overlay is going to be. */ 3729 /* Redisplay where the overlay is going to be. */
3727 modify_overlay (b, XINT (beg), XINT (end)); 3730 modify_overlay (b, n_beg, n_end);
3728 } 3731 }
3729 else 3732 else
3730 /* Redisplay the area the overlay has just left, or just enclosed. */ 3733 /* Redisplay the area the overlay has just left, or just enclosed. */
@@ -3734,16 +3737,12 @@ buffer. */)
3734 o_beg = OVERLAY_POSITION (OVERLAY_START (overlay)); 3737 o_beg = OVERLAY_POSITION (OVERLAY_START (overlay));
3735 o_end = OVERLAY_POSITION (OVERLAY_END (overlay)); 3738 o_end = OVERLAY_POSITION (OVERLAY_END (overlay));
3736 3739
3737 if (o_beg == XINT (beg)) 3740 if (o_beg == n_beg)
3738 modify_overlay (b, o_end, XINT (end)); 3741 modify_overlay (b, o_end, n_end);
3739 else if (o_end == XINT (end)) 3742 else if (o_end == n_end)
3740 modify_overlay (b, o_beg, XINT (beg)); 3743 modify_overlay (b, o_beg, n_beg);
3741 else 3744 else
3742 { 3745 modify_overlay (b, min (o_beg, n_beg), max (o_end, n_end));
3743 if (XINT (beg) < o_beg) o_beg = XINT (beg);
3744 if (XINT (end) > o_end) o_end = XINT (end);
3745 modify_overlay (b, o_beg, o_end);
3746 }
3747 } 3746 }
3748 3747
3749 if (!NILP (obuffer)) 3748 if (!NILP (obuffer))
@@ -3755,12 +3754,8 @@ buffer. */)
3755 eassert (XOVERLAY (overlay)->next == NULL); 3754 eassert (XOVERLAY (overlay)->next == NULL);
3756 } 3755 }
3757 3756
3758 Fset_marker (OVERLAY_START (overlay), beg, buffer);
3759 Fset_marker (OVERLAY_END (overlay), end, buffer);
3760
3761 /* Put the overlay on the wrong list. */ 3757 /* Put the overlay on the wrong list. */
3762 end = OVERLAY_END (overlay); 3758 if (n_end < b->overlay_center)
3763 if (OVERLAY_POSITION (end) < b->overlay_center)
3764 { 3759 {
3765 XOVERLAY (overlay)->next = b->overlays_after; 3760 XOVERLAY (overlay)->next = b->overlays_after;
3766 b->overlays_after = XOVERLAY (overlay); 3761 b->overlays_after = XOVERLAY (overlay);