diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-10-09 19:45:26 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 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.tar.bz2 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); extern void mmap_set_vars (bool); extern void restore_buffer (Lisp_Object); extern void set_buffer_if_live (Lisp_Object); +extern Lisp_Object build_overlay (bool, bool, Lisp_Object); /* Return B as a struct buffer pointer, defaulting to the current buffer. */ @@ -1408,40 +1409,6 @@ overlay_end (struct Lisp_Overlay *ov) return interval_node_end (ov->buffer->overlays, ov->interval); } -INLINE void -set_overlay_region (struct Lisp_Overlay *ov, ptrdiff_t begin, ptrdiff_t end) -{ - eassert (ov->buffer); - begin = clip_to_bounds (BEG, begin, ov->buffer->text->z); - end = clip_to_bounds (begin, end, ov->buffer->text->z); - interval_node_set_region (ov->buffer->overlays, ov->interval, begin, end); -} - -INLINE void -maybe_alloc_buffer_overlays (struct buffer *b) -{ - if (! b->overlays) - b->overlays = interval_tree_create (); -} - -INLINE void -add_buffer_overlay (struct buffer *b, struct Lisp_Overlay *ov) -{ - eassert (! ov->buffer); - maybe_alloc_buffer_overlays (b); - ov->buffer = b; - interval_tree_insert (b->overlays, ov->interval); -} - -INLINE void -remove_buffer_overlay (struct buffer *b, struct Lisp_Overlay *ov) -{ - eassert (b->overlays); - eassert (ov->buffer == b); - interval_tree_remove (ov->buffer->overlays, ov->interval); - ov->buffer = NULL; -} - /* Return the start of OV in its buffer, or -1 if OV is not associated with any buffer. */ |