diff options
| author | Stefan Monnier | 2022-10-09 19:45:26 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2022-10-09 19:45:26 -0400 |
| commit | 7cbeeabc7e6271948e7bb93020c2e4e50c65f384 (patch) | |
| tree | 777b281d62878ab7cc5a12b7e3fbc8952bf95dbc /src/buffer.h | |
| parent | 4f3f7aebc957732f4fbe5c799da5367f46607680 (diff) | |
| download | emacs-7cbeeabc7e6271948e7bb93020c2e4e50c65f384.tar.gz emacs-7cbeeabc7e6271948e7bb93020c2e4e50c65f384.zip | |
Tighten up handling of `otick`
Move args between `build_overlay` and `add_buffer_overlay`,
to try and keep buffer positions together with their buffer.
Be more strict in the `otick` values passed to `interval_tree_insert`.
Move a few things around to try and reduce dependencies through `.h` files.
Fix a thinko bug in `check_tree`.
* src/alloc.c (build_overlay): Remove `begin` and `end` args.
* src/buffer.c (add_buffer_overlay): Move from `buffer.h`.
Add `begin` and `end` args.
(copy_overlays): Adjust accordingly.
(Fmake_overlay): Use BUF_BEG and BUF_Z; adjust call to `build_overlay`
and `add_buffer_overlay`.
(Fmove_overlay): Use BUF_BEG and BUF_Z; Use the new `begin` and `end`
args of `add_buffer_overlay` so we don't need to use
`interval_node_set_region` when moving to a new buffer.
(remove_buffer_overlay, set_overlay_region): Move from `buffer.h`.
* src/buffer.h (set_overlay_region, add_buffer_overlay)
(remove_buffer_overlay): Move to `buffer.c`.
(build_overlay): Move from `lisp.h`.
(maybe_alloc_buffer_overlays): Delete function (inline into its only
caller).
* src/itree.c (interval_tree_insert): Move declaration `from buffer.h`.
(check_tree): Fix initial offset in call to `recurse_check_tree`.
Remove redundant check of the `limit` value.
(interval_node_init): Remove `begin` and `end` args.
(interval_tree_insert): Mark it as static.
Assert that the new node's `otick` should already be uptodate and its
new parent as well.
(itree_insert_node): New function.
(interval_tree_insert_gap): Assert the otick of the removed+added nodes
were uptodate and mark them as uptodate again after adjusting
their positions.
(interval_tree_inherit_offset): Check that the parent is at least as
uptodate as the child.
* src/lisp.h (build_overlay): Move to `buffer.h`.
* src/itree.h (interval_node_init): Adjust accordingly.
(interval_tree_insert): Remove declaration.
(itree_insert_node): New declaration.
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/src/buffer.h b/src/buffer.h index a4e3934cad2..288acd4f5ee 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -1189,6 +1189,7 @@ extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); | |||
| 1189 | extern void mmap_set_vars (bool); | 1189 | extern void mmap_set_vars (bool); |
| 1190 | extern void restore_buffer (Lisp_Object); | 1190 | extern void restore_buffer (Lisp_Object); |
| 1191 | extern void set_buffer_if_live (Lisp_Object); | 1191 | extern void set_buffer_if_live (Lisp_Object); |
| 1192 | extern Lisp_Object build_overlay (bool, bool, Lisp_Object); | ||
| 1192 | 1193 | ||
| 1193 | /* Return B as a struct buffer pointer, defaulting to the current buffer. */ | 1194 | /* Return B as a struct buffer pointer, defaulting to the current buffer. */ |
| 1194 | 1195 | ||
| @@ -1408,40 +1409,6 @@ overlay_end (struct Lisp_Overlay *ov) | |||
| 1408 | return interval_node_end (ov->buffer->overlays, ov->interval); | 1409 | return interval_node_end (ov->buffer->overlays, ov->interval); |
| 1409 | } | 1410 | } |
| 1410 | 1411 | ||
| 1411 | INLINE void | ||
| 1412 | set_overlay_region (struct Lisp_Overlay *ov, ptrdiff_t begin, ptrdiff_t end) | ||
| 1413 | { | ||
| 1414 | eassert (ov->buffer); | ||
| 1415 | begin = clip_to_bounds (BEG, begin, ov->buffer->text->z); | ||
| 1416 | end = clip_to_bounds (begin, end, ov->buffer->text->z); | ||
| 1417 | interval_node_set_region (ov->buffer->overlays, ov->interval, begin, end); | ||
| 1418 | } | ||
| 1419 | |||
| 1420 | INLINE void | ||
| 1421 | maybe_alloc_buffer_overlays (struct buffer *b) | ||
| 1422 | { | ||
| 1423 | if (! b->overlays) | ||
| 1424 | b->overlays = interval_tree_create (); | ||
| 1425 | } | ||
| 1426 | |||
| 1427 | INLINE void | ||
| 1428 | add_buffer_overlay (struct buffer *b, struct Lisp_Overlay *ov) | ||
| 1429 | { | ||
| 1430 | eassert (! ov->buffer); | ||
| 1431 | maybe_alloc_buffer_overlays (b); | ||
| 1432 | ov->buffer = b; | ||
| 1433 | interval_tree_insert (b->overlays, ov->interval); | ||
| 1434 | } | ||
| 1435 | |||
| 1436 | INLINE void | ||
| 1437 | remove_buffer_overlay (struct buffer *b, struct Lisp_Overlay *ov) | ||
| 1438 | { | ||
| 1439 | eassert (b->overlays); | ||
| 1440 | eassert (ov->buffer == b); | ||
| 1441 | interval_tree_remove (ov->buffer->overlays, ov->interval); | ||
| 1442 | ov->buffer = NULL; | ||
| 1443 | } | ||
| 1444 | |||
| 1445 | /* Return the start of OV in its buffer, or -1 if OV is not associated | 1412 | /* Return the start of OV in its buffer, or -1 if OV is not associated |
| 1446 | with any buffer. */ | 1413 | with any buffer. */ |
| 1447 | 1414 | ||