diff options
| author | Stefan Monnier | 2018-10-14 16:44:21 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2018-10-14 16:44:21 -0400 |
| commit | 8c68e4afa8eebb6f738fdce600a6815509ac50a3 (patch) | |
| tree | 36bfa55ae5bcf1f36a7c5754ca1a4729cace4c1d /src/buffer.c | |
| parent | f1ea2b9e6b63593f5919f60a68a9e19026756ac4 (diff) | |
| download | emacs-8c68e4afa8eebb6f738fdce600a6815509ac50a3.tar.gz emacs-8c68e4afa8eebb6f738fdce600a6815509ac50a3.zip | |
* src/buffer.c (Fmove_overlay): Don't call Fdelete_overlay
... because the data structure is not in a consistent state.
* test/src/buffer-tests.el (overlay-evaporation-after-killed-buffer):
New test.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index 024e64f0d74..ac2de7d19f2 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -3991,6 +3991,16 @@ buffer. */) | |||
| 3991 | 3991 | ||
| 3992 | unchain_both (ob, overlay); | 3992 | unchain_both (ob, overlay); |
| 3993 | } | 3993 | } |
| 3994 | else | ||
| 3995 | /* An overlay not associated with any buffer will normally have its | ||
| 3996 | `next' field set to NULL, but not always: when killing a buffer, | ||
| 3997 | we just set its overlays_after and overlays_before to NULL without | ||
| 3998 | manually setting each overlay's `next' field to NULL. | ||
| 3999 | Let's correct it here, to simplify subsequent assertions. | ||
| 4000 | FIXME: Maybe the better fix is to change `kill-buffer'!? */ | ||
| 4001 | XOVERLAY (overlay)->next = NULL; | ||
| 4002 | |||
| 4003 | eassert (XOVERLAY (overlay)->next == NULL); | ||
| 3994 | 4004 | ||
| 3995 | /* Set the overlay boundaries, which may clip them. */ | 4005 | /* Set the overlay boundaries, which may clip them. */ |
| 3996 | Fset_marker (OVERLAY_START (overlay), beg, buffer); | 4006 | Fset_marker (OVERLAY_START (overlay), beg, buffer); |
| @@ -4020,10 +4030,20 @@ buffer. */) | |||
| 4020 | modify_overlay (b, min (o_beg, n_beg), max (o_end, n_end)); | 4030 | modify_overlay (b, min (o_beg, n_beg), max (o_end, n_end)); |
| 4021 | } | 4031 | } |
| 4022 | 4032 | ||
| 4033 | eassert (XOVERLAY (overlay)->next == NULL); | ||
| 4034 | |||
| 4023 | /* Delete the overlay if it is empty after clipping and has the | 4035 | /* Delete the overlay if it is empty after clipping and has the |
| 4024 | evaporate property. */ | 4036 | evaporate property. */ |
| 4025 | if (n_beg == n_end && !NILP (Foverlay_get (overlay, Qevaporate))) | 4037 | if (n_beg == n_end && !NILP (Foverlay_get (overlay, Qevaporate))) |
| 4026 | return unbind_to (count, Fdelete_overlay (overlay)); | 4038 | { /* We used to call `Fdelete_overlay' here, but it causes problems: |
| 4039 | - At this stage, `overlay' is not included in its buffer's lists | ||
| 4040 | of overlays (the data-structure is in an inconsistent state), | ||
| 4041 | contrary to `Fdelete_overlay's assumptions. | ||
| 4042 | - Most of the work done by Fdelete_overlay has already been done | ||
| 4043 | here for other reasons. */ | ||
| 4044 | drop_overlay (XBUFFER (buffer), XOVERLAY (overlay)); | ||
| 4045 | return unbind_to (count, overlay); | ||
| 4046 | } | ||
| 4027 | 4047 | ||
| 4028 | /* Put the overlay into the new buffer's overlay lists, first on the | 4048 | /* Put the overlay into the new buffer's overlay lists, first on the |
| 4029 | wrong list. */ | 4049 | wrong list. */ |