From: Joakim Jalap <joakim.jalap@fastmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Overlays as an AA-tree
Date: Tue, 20 Sep 2016 19:13:38 +0200 [thread overview]
Message-ID: <87lgymjxz1.fsf@fastmail.com> (raw)
In-Reply-To: <838tumhbx1.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 20 Sep 2016 17:40:42 +0300")
[-- Attachment #1: Type: text/plain, Size: 2695 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
> It seems like you only attached part of the changes, because all I see
> in the attachment is 3 entirely new files, with no ifdef's anywhere in
> sight. So I couldn't look at the problems that got you stuck.
Yes, sorry. Attaching the full diff.
> Just by reading your description, I don't think I understand the
> nature of your difficulties. Overlays present a relatively small
> number of Lisp-visible APIs, so all you need is to re-implement those
> few APIs based on the new internal representation. What exactly gives
> you trouble with that? (I see you've implemented new APIs, but that
> doesn't have to be part of the job, it's up to you.)
Well, the Lisp-visible APIs weren't really the problem. The problem was
more in the 'internal' handling of overlays in buffer.c and in xdisp.c,
and also the fact that I had to reimplement a lot of the logic about how
markers are moved when the buffer changes. Speaking of which, is the
byte position stored in a marker of any significance in an overlay?
Otherwise I could at least get rid of those.
I don't really think it's anything that's monumentally difficult, it's
more that until everything works nothing really works, so I can't even
get Emacs to start.
The DEFUNs I added in overlays.c were just for my own debugging purposes
while writing the code, it's nothing I intended to keep.
> As for the migration path: if you find it difficult to keep the old
> code, just remove it. When your code is ready for testing by others,
> you could push a public Git branch and ask people to check it out. We
> won't merge the branch to master until it is stable enough, so the
> fact that the old implementation will be gone is not a problem. (If
> needed, we can always compare with older versions to see if some issue
> is due to the new implementation or not.)
>
> You say that replacing it all is very hard, but I don't really
> understand why. Please elaborate.
Well, first of all I thought it would be a good strategy to keep all the
old code so that I could compare the results at runtime, but that turned
into a huge mess of ifdefs.
Secondly I thought that it'd be slightly easier to iterate while keeping
the old code, but that turned out to be harder than I first imagined.
Basically my problem is that when I throw the old code out wholesale,
suddenly that's thousands of lines I have to write which have to
somewhat work, or I can't even get Emacs to build, let alone start up,
so it turns into quite a big project, which I don't really see how I can
break up into smaller parts.
> Thanks again for your efforts. Please keep up the good work.
Thanks! I'll keep working on it :)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Complete diff --]
[-- Type: text/x-diff, Size: 64277 bytes --]
diff --git a/configure.ac b/configure.ac
index b7651ed..2674806 100644
--- a/configure.ac
+++ b/configure.ac
@@ -378,12 +378,6 @@ AC_DEFUN
OPTION_DEFAULT_OFF([xwidgets],
[enable use of some gtk widgets in Emacs buffers (requires gtk3)])
-OPTION_DEFAULT_OFF([new_overlays],
- [Use AA-tree for overlays])
-
-OPTION_DEFAULT_OFF([both_overlays],
- [Use both overlays and a lot of assertions])
-
## For the times when you want to build Emacs but don't have
## a suitable makeinfo, and can live without the manuals.
dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.html
@@ -2648,35 +2642,6 @@ AC_DEFUN
CFLAGS=$OLD_CFLAGS
LIBS=$OLD_LIBS
-
-BOTH_OVERLAYS=no
-NEW_OVERLAYS=no
-OVERLAYS_OBJ=
-OVERLAYS_H=
-if test "$with_new_overlays" != "no"; then
- if test "$with_both_overlays" != "no"; then
- AS_ECHO([both? ${BOTH_OVERLAYS} $with_new_overlays $with_both_overlays])
- AC_MSG_ERROR([Can't have both new-overlays and both-overlays.])
- fi
- NEW_OVERLAYS=yes
- AC_DEFINE([NEW_OVERLAYS], 1, [Use new overlays.])
- OVERLAYS_OBJ=overlays.o
- OVERLAYS_H=overlays.h
-fi
-
-if test "$with_both_overlays" != "no"; then
- if test "x$ac_enable_checking" == "x" ; then
- AC_MSG_ERROR([with-both_overlays only makes sense with enable-checking])
- fi
- BOTH_OVERLAYS=yes
- AC_DEFINE([BOTH_OVERLAYS], 1, [Use both overlays.])
- OVERLAYS_OBJ=overlays.o
- OVERLAYS_H=overlays.h
-fi
-AC_SUBST(OVERLAYS_OBJ)
-AC_SUBST(OVERLAYS_H)
-
-
dnl D-Bus has been tested under GNU/Linux only. Must be adapted for
dnl other platforms.
HAVE_DBUS=no
@@ -5319,8 +5284,6 @@ AC_DEFUN
Does Emacs have dynamic modules support? ${HAVE_MODULES}
Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SCROLL_BARS}
Does Emacs support Xwidgets (requires gtk3)? ${HAVE_XWIDGETS}
- Does Emacs use both overlay structures? ${BOTH_OVERLAYS}
- Does Emacs use AA-tree for overlays? ${NEW_OVERLAYS}
"])
if test -n "${EMACSDATA}"; then
diff --git a/src/Makefile.in b/src/Makefile.in
index 89c0c2a..8639eff 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -156,8 +156,6 @@ DBUS_OBJ =
## xwidgets.o if HAVE_XWIDGETS, else empty.
XWIDGETS_OBJ = @XWIDGETS_OBJ@
-OVERLAYS_OBJ = @OVERLAYS_OBJ@
-
LIB_EXECINFO=@LIB_EXECINFO@
SETTINGS_CFLAGS = @SETTINGS_CFLAGS@
@@ -398,7 +396,7 @@ base_obj =
$(CM_OBJ) term.o terminal.o xfaces.o $(XOBJ) $(GTK_OBJ) $(DBUS_OBJ) \
emacs.o keyboard.o macros.o keymap.o sysdep.o \
buffer.o filelock.o insdel.o marker.o \
- minibuf.o fileio.o dired.o $(OVERLAYS_OBJ) \
+ minibuf.o fileio.o dired.o \
cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o \
alloc.o data.o doc.o editfns.o callint.o \
eval.o floatfns.o fns.o font.o print.o lread.o $(MODULES_OBJ) \
diff --git a/src/alloc.c b/src/alloc.c
index 2ec7dae..5f9d6ad 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3799,18 +3799,6 @@ build_overlay (Lisp_Object start, Lisp_Object end, Lisp_Object plist)
OVERLAY_END (overlay) = end;
set_overlay_plist (overlay, plist);
XOVERLAY (overlay)->next = NULL;
-
-#ifdef NEW_OVERLAYS
- XOVERLAY (overlay)->left = NULL;
- XOVERLAY (overlay)->right = NULL;
- ptrdiff_t char_start = XINT (Fmarker_position (start));
- XOVERLAY (overlay)->char_start = char_start;
- XOVERLAY (overlay)->byte_start = CHAR_TO_BYTE(char_start);
- ptrdiff_t char_end = XINT (Fmarker_position(end));
- XOVERLAY (overlay)->char_end = char_end;
- XOVERLAY (overlay)->byte_end = CHAR_TO_BYTE(char_end);
-#endif
-
return overlay;
}
diff --git a/src/buffer.c b/src/buffer.c
index cca91c7..8756cbb 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -43,10 +43,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "frame.h"
#include "xwidget.h"
-#if defined (NEW_OVERLAYS) || defined (BOTH_OVERLAYS)
-#include "overlays.h"
-#endif
-
#ifdef WINDOWSNT
#include "w32heap.h" /* for mmap_* */
#endif
@@ -125,7 +121,7 @@ static Lisp_Object QSFundamental; /* A string "Fundamental". */
static void alloc_buffer_text (struct buffer *, ptrdiff_t);
static void free_buffer_text (struct buffer *b);
static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *);
-void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t);
+static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t);
static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool);
static void
@@ -596,23 +592,6 @@ even if it is dead. The return value is never nil. */)
return buffer;
}
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
-static void INLINE
-insert_overlay_in_buffer_tree (struct buffer *b, Lisp_Object overlay)
-{
- struct Lisp_Overlay *o = XOVERLAY (overlay);
- if (b->overlays_root == OVERLAY_SENTINEL)
- {
- overlay_tree_insert (&b->overlays_root, o);
- eassert (b->overlays_root == o);
- XSETBUFFER(b->overlays_root->parent, b);
- }
- else
- {
- overlay_tree_insert (&b->overlays_root, o);
- }
-}
-#endif
/* Return a list of overlays which is a copy of the overlay list
LIST, but for buffer B. */
@@ -646,7 +625,7 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list)
return result;
}
-#ifndef NEW_OVERLAYS
+
/* Set an appropriate overlay of B. */
static void
@@ -660,7 +639,6 @@ set_buffer_overlays_after (struct buffer *b, struct Lisp_Overlay *o)
{
b->overlays_after = o;
}
-#endif
/* Clone per-buffer values of buffer FROM.
@@ -882,7 +860,6 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
return buf;
}
-#ifndef NEW_OVERLAYS
/* Mark OV as no longer associated with B. */
static void
@@ -895,14 +872,12 @@ drop_overlay (struct buffer *b, struct Lisp_Overlay *ov)
unchain_marker (XMARKER (ov->end));
}
-#endif
/* Delete all overlays of B and reset it's overlay lists. */
void
delete_all_overlays (struct buffer *b)
{
-#ifndef NEW_OVERLAYS
struct Lisp_Overlay *ov, *next;
/* FIXME: Since each drop_overlay will scan BUF_MARKERS to unlink its
@@ -923,9 +898,6 @@ delete_all_overlays (struct buffer *b)
set_buffer_overlays_before (b, NULL);
set_buffer_overlays_after (b, NULL);
-#else
- overlay_tree_drop_all (b);
-#endif
}
/* Reinitialize everything about a buffer except its name and contents
@@ -953,11 +925,9 @@ reset_buffer (register struct buffer *b)
b->auto_save_failure_time = 0;
bset_auto_save_file_name (b, Qnil);
bset_read_only (b, Qnil);
-#ifndef NEW_OVERLAYS
set_buffer_overlays_before (b, NULL);
set_buffer_overlays_after (b, NULL);
b->overlay_center = BEG;
-#endif
bset_mark_active (b, Qnil);
bset_point_before_scroll (b, Qnil);
bset_file_format (b, Qnil);
@@ -971,9 +941,6 @@ reset_buffer (register struct buffer *b)
bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing));
b->display_error_modiff = 0;
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
- b->overlays_root = OVERLAY_SENTINEL;
-#endif
}
/* Reset buffer B's local variables info.
@@ -2788,7 +2755,6 @@ overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr,
ptrdiff_t *len_ptr,
ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, bool change_req)
{
-#ifndef NEW_OVERLAYS
Lisp_Object overlay, start, end;
struct Lisp_Overlay *tail;
ptrdiff_t idx = 0;
@@ -2895,52 +2861,7 @@ overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr,
*next_ptr = next;
if (prev_ptr)
*prev_ptr = prev;
-
-#ifdef BOTH_OVERLAYS
- ptrdiff_t check_next, check_prev, check_len = 20, check_idx;
- Lisp_Object *check_vec;
-
- check_vec = xnmalloc(check_len, sizeof *check_vec);
-
- check_idx = overlay_tree_at (current_buffer->overlays_root,
- pos, &check_next, &check_prev,
- &check_len, &check_vec,
- change_req);
-
- /* Same amount of overlays returned. */
- /* eassert (check_idx == idx); */
- /* Same NEXT_PTR. */
- if (next_ptr)
- eassert (*next_ptr == check_next);
- /* Same PREV_PTR. */
- if (prev_ptr)
- eassert (*prev_ptr == check_prev);
-
- /* Finally check that all overlays in *VEC_PTR are also in
- CHECK_VEC. */
- ptrdiff_t i, j;
- bool found;
- for (i = 0; i < idx; i++)
- {
- found = false;
- struct Lisp_Overlay *o1 = XOVERLAY ((*vec_ptr)[i]);
- for (j = 0; j < idx; j++)
- {
- struct Lisp_Overlay *o2 = XOVERLAY (check_vec[j]);
- if (o1 == o2)
- found = true;
- }
- if (!found)
- eassert (false);
- }
-
-#endif /* BOTH_OVERLAYS */
return idx;
-#else /* if NEW_OVERLAYS */
- return overlay_tree_at (current_buffer->overlays_root, pos,
- next_ptr, prev_ptr, len_ptr, vec_ptr,
- change_req)
-#endif /* ifndef NEW_OVERLAYS */
}
\f
/* Find all the overlays in the current buffer that overlap the range
@@ -3206,14 +3127,8 @@ sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w)
overlay = overlay_vec[i];
if (OVERLAYP (overlay)
-#ifndef NEW_OVERLAYS
&& OVERLAY_POSITION (OVERLAY_START (overlay)) > 0
- && OVERLAY_POSITION (OVERLAY_END (overlay)) > 0
-#else
- && XOVERLAY (overlay)->char_start > 0
- && XOVERLAY (overlay)->char_end > 0
-#endif
- )
+ && OVERLAY_POSITION (OVERLAY_END (overlay)) > 0)
{
/* If we're interested in a specific window, then ignore
overlays that are limited to some other window. */
@@ -3228,17 +3143,8 @@ sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w)
/* This overlay is good and counts: put it into sortvec. */
sortvec[j].overlay = overlay;
-#ifndef NEW_OVERLAYS
sortvec[j].beg = OVERLAY_POSITION (OVERLAY_START (overlay));
sortvec[j].end = OVERLAY_POSITION (OVERLAY_END (overlay));
-#ifdef BOTH_OVERLAYS
- eassert (sortvec[j].beg == XOVERLAY (overlay)->char_start);
- eassert (sortvec[j].end == XOVERLAY (overlay)->char_end);
-#endif
-#else
- sortvec[j].beg = XOVERLAY (overlay)->char_start;
- sortvec[j].end = XOVERLAY (overlay)->char_end;
-#endif
tem = Foverlay_get (overlay, Qpriority);
if (NILP (tem))
{
@@ -3488,7 +3394,6 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
return 0;
}
\f
-#ifndef NEW_OVERLAYS
/* Shift overlays in BUF's overlay lists, to center the lists at POS. */
void
@@ -3637,7 +3542,7 @@ adjust_overlays_for_delete (ptrdiff_t pos, ptrdiff_t length)
and also update the center point. */
recenter_overlay_lists (current_buffer, pos);
}
-#endif
+
/* Fix up overlays that were garbled as a result of permuting markers
in the range START through END. Any overlay with at least one
endpoint in this range will need to be unlinked from the overlay
@@ -3912,7 +3817,6 @@ for the rear of the overlay advance when text is inserted there
b = XBUFFER (buffer);
-#ifndef NEW_OVERLAYS
beg = Fset_marker (Fmake_marker (), beg, buffer);
end = Fset_marker (Fmake_marker (), end, buffer);
@@ -3920,20 +3824,9 @@ for the rear of the overlay advance when text is inserted there
XMARKER (beg)->insertion_type = 1;
if (!NILP (rear_advance))
XMARKER (end)->insertion_type = 1;
-#endif
overlay = build_overlay (beg, end, Qnil);
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
- XOVERLAY (overlay)->start_insertion_type = !NILP (front_advance);
- XOVERLAY (overlay)->end_insertion_type = !NILP (rear_advance);
-
- insert_overlay_in_buffer_tree(b, overlay);
-#ifdef BOTH_OVERLAYS
- /* Check coherence */
-#endif /* BOTH_OVERLAYS */
-#endif /* NEW_OVERLAYS or BOTH_OVERLAYS */
-#ifndef NEW_OVERLAYS
/* Put the new overlay on the wrong list. */
end = OVERLAY_END (overlay);
if (OVERLAY_POSITION (end) < b->overlay_center)
@@ -3953,13 +3846,13 @@ for the rear of the overlay advance when text is inserted there
/* We don't need to redisplay the region covered by the overlay, because
the overlay has no properties at the moment. */
-#endif
+
return overlay;
}
\f
/* Mark a section of BUF as needing redisplay because of overlays changes. */
-void
+static void
modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
{
if (start > end)
@@ -3976,7 +3869,6 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
++BUF_OVERLAY_MODIFF (buf);
}
-#ifndef NEW_OVERLAYS
/* Remove OVERLAY from LIST. */
static struct Lisp_Overlay *
@@ -4005,7 +3897,6 @@ unchain_both (struct buffer *b, Lisp_Object overlay)
set_buffer_overlays_after (b, unchain_overlay (b->overlays_after, ov));
eassert (XOVERLAY (overlay)->next == NULL);
}
-#endif
DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0,
doc: /* Set the endpoints of OVERLAY to BEG and END in BUFFER.
@@ -4019,23 +3910,10 @@ buffer. */)
ptrdiff_t count = SPECPDL_INDEX ();
ptrdiff_t n_beg, n_end;
ptrdiff_t o_beg UNINIT, o_end UNINIT;
-#if defined(NEW_OVERLAYS ) || defined(BOTH_OVERLAYS)
- ptrdiff_t old_start UNINIT, old_end UNINIT;
-#endif
+
CHECK_OVERLAY (overlay);
if (NILP (buffer))
- {
-#ifndef NEW_OVERLAYS
- buffer = Fmarker_buffer (OVERLAY_START (overlay));
-#ifdef BOTH_OVERLAYS
- struct buffer *b1 = XBUFFER (buffer);
- struct buffer *b2 = XBUFFER (buffer_of_overlay (overlay));
- eassert (b1 == b2);
-#endif
-#else /* NEW_OVERLAYS */
- buffer = buffer_of_overlay (overlay);
-#endif
- }
+ buffer = Fmarker_buffer (OVERLAY_START (overlay));
if (NILP (buffer))
XSETBUFFER (buffer, current_buffer);
CHECK_BUFFER (buffer);
@@ -4059,68 +3937,33 @@ buffer. */)
specbind (Qinhibit_quit, Qt);
-#ifndef NEW_OVERLAYS
obuffer = Fmarker_buffer (OVERLAY_START (overlay));
-#ifdef BOTH_OVERLAYS
- Lisp_Object obuffer2 = buffer_of_overlay (overlay);
- struct buffer *ob1 = XBUFFER (obuffer);
- struct buffer *ob2 = XBUFFER (obuffer2);
- eassert (ob1 == ob2);
-#endif
-#else
- obuffer = buffer_of_overlay (overlay);
-#endif
b = XBUFFER (buffer);
if (!NILP (obuffer))
{
ob = XBUFFER (obuffer);
-#ifndef NEW_OVERLAYS
+
o_beg = OVERLAY_POSITION (OVERLAY_START (overlay));
o_end = OVERLAY_POSITION (OVERLAY_END (overlay));
unchain_both (ob, overlay);
-#endif
-
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
- old_start = XOVERLAY (overlay)->char_start;
- old_end = XOVERLAY (overlay)->char_end;
- overlay_tree_delete(&ob->overlays_root, XOVERLAY (overlay));
-#ifdef BOTH_OVERLAYS
- eassert (o_beg == old_start);
- eassert (o_end == old_end);
-#endif
-#endif
}
-#ifndef NEW_OVERLAYS
+
/* Set the overlay boundaries, which may clip them. */
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));
-#endif
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
- ptrdiff_t new_start = clip_to_bounds (BUF_BEG (b), XINT (beg),
- BUF_Z (b));
- ptrdiff_t new_end = clip_to_bounds(BUF_BEG (b), XINT (end),
- BUF_Z (b));
-#ifdef BOTH_OVERLAYS
- eassert (n_beg == new_start);
- eassert (n_end == new_end);
-#endif /* BPTH_OVERLAYS */
- XOVERLAY (overlay)->char_start = new_start;
- XOVERLAY (overlay)->char_end = new_end;
-#endif /* NEW_OVERLAYS || BOTH_OVERLAYS */
-
-#ifndef NEW_OVERLAYS
/* If the overlay has changed buffers, do a thorough redisplay. */
if (!EQ (buffer, obuffer))
{
/* Redisplay where the overlay was. */
if (ob)
modify_overlay (ob, o_beg, o_end);
+
/* Redisplay where the overlay is going to be. */
modify_overlay (b, n_beg, n_end);
}
@@ -4139,35 +3982,7 @@ buffer. */)
evaporate property. */
if (n_beg == n_end && !NILP (Foverlay_get (overlay, Qevaporate)))
return unbind_to (count, Fdelete_overlay (overlay));
-#else
- /* If the overlay has changed buffers, do a thorough redisplay. */
- if (!EQ (buffer, obuffer))
- {
- /* Redisplay where the overlay was. */
- if (ob)
- modify_overlay (ob, old_start, old_end);
- /* Redisplay where the overlay is going to be. */
- modify_overlay (b, new_start, new_end);
- }
- else
- /* Redisplay the area the overlay has just left, or just enclosed. */
- {
- if (old_start == new_start)
- modify_overlay (b, old_end, new_end);
- else if (old_end == new_end)
- modify_overlay (b, old_start, new_start);
- else
- modify_overlay (b, min (old_start, new_start),
- max (old_end, new_end));
- }
- /* Delete the overlay if it is empty after clipping and has the
- evaporate property. */
- if (new_start == new_end && !NILP (Foverlay_get (overlay, Qevaporate)))
- return unbind_to (count, Fdelete_overlay (overlay));
-#endif
-
-#ifndef NEW_OVERLAYS
/* Put the overlay into the new buffer's overlay lists, first on the
wrong list. */
if (n_end < b->overlay_center)
@@ -4183,9 +3998,7 @@ buffer. */)
/* This puts it in the right list, and in the right order. */
recenter_overlay_lists (b, b->overlay_center);
-#else
- insert_overlay_in_buffer_tree(b, overlay);
-#endif
+
return unbind_to (count, overlay);
}
@@ -4198,28 +4011,16 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
ptrdiff_t count = SPECPDL_INDEX ();
CHECK_OVERLAY (overlay);
-#ifndef NEW_OVERLAYS
+
buffer = Fmarker_buffer (OVERLAY_START (overlay));
-#ifdef BOTH_OVERLAYS
- struct buffer *b1 = XBUFFER (buffer);
- struct buffer *b2 = XBUFFER (buffer_of_overlay (overlay));
- eassert (b1 == b2);
-#endif /* ifdef BOTH_OVERLAYS */
-#else
- buffer = buffer_of_overlay (overlay);
-#endif
if (NILP (buffer))
return Qnil;
b = XBUFFER (buffer);
specbind (Qinhibit_quit, Qt);
-#ifndef NEW_OVERLAYS
unchain_both (b, overlay);
drop_overlay (b, XOVERLAY (overlay));
-#else
- overlay_tree_delete(&b->overlays_root, XOVERLAY (overlay));
-#endif
/* When deleting an overlay with before or after strings, turn off
display optimizations for the affected buffer, on the basis that
@@ -4251,17 +4052,7 @@ DEFUN ("overlay-start", Foverlay_start, Soverlay_start, 1, 1, 0,
{
CHECK_OVERLAY (overlay);
-#ifdef NEW_OVERLAYS
- return make_number (XOVERLAY (overlay)->char_start);
-#else
-#ifdef BOTH_OVERLAYS
- Lisp_Object a[2];
- a[0] = make_number(XOVERLAY (overlay)->char_start);
- a[1] = Fmarker_position (OVERLAY_START (overlay));
- eassert (Feqlsign (2, a));
-#endif
- return Fmarker_position (OVERLAY_START (overlay));
-#endif
+ return (Fmarker_position (OVERLAY_START (overlay)));
}
DEFUN ("overlay-end", Foverlay_end, Soverlay_end, 1, 1, 0,
@@ -4270,17 +4061,7 @@ DEFUN ("overlay-end", Foverlay_end, Soverlay_end, 1, 1, 0,
{
CHECK_OVERLAY (overlay);
-#ifdef NEW_OVERLAYS
- return make_number (XOVERLAY (overlay)->char_end);
-#else
-#ifdef BOTH_OVERLAYS
- Lisp_Object a[2];
- a[0] = make_number(XOVERLAY (overlay)->char_end);
- a[1] = Fmarker_position (OVERLAY_END (overlay));
- eassert (Feqlsign (2, a));
-#endif
- return Fmarker_position (OVERLAY_END (overlay));
-#endif
+ return (Fmarker_position (OVERLAY_END (overlay)));
}
DEFUN ("overlay-buffer", Foverlay_buffer, Soverlay_buffer, 1, 1, 0,
@@ -4290,17 +4071,7 @@ Return nil if OVERLAY has been deleted. */)
{
CHECK_OVERLAY (overlay);
-#ifdef NEW_OVERLAYS
- return buffer_of_overlay (overlay);
-#else
-#ifdef BOTH_OVERLAYS
- struct buffer *b1, *b2;
- b1 = XBUFFER (buffer_of_overlay (overlay));
- b2 = XBUFFER (Fmarker_buffer(OVERLAY_START (overlay)));
- eassert (b1 == b2);
-#endif
return Fmarker_buffer (OVERLAY_START (overlay));
-#endif
}
DEFUN ("overlay-properties", Foverlay_properties, Soverlay_properties, 1, 1, 0,
@@ -4470,7 +4241,6 @@ The lists you get are copies, so that changing them has no effect.
However, the overlays you get are the real objects that the buffer uses. */)
(void)
{
-#ifndef NEW_OVERLAYS
struct Lisp_Overlay *ol;
Lisp_Object before = Qnil, after = Qnil, tmp;
@@ -4486,9 +4256,6 @@ However, the overlays you get are the real objects that the buffer uses. */)
}
return Fcons (Fnreverse (before), Fnreverse (after));
-#else
- return Qnil;
-#endif
}
DEFUN ("overlay-recenter", Foverlay_recenter, Soverlay_recenter, 1, 1, 0,
@@ -4497,13 +4264,11 @@ That makes overlay lookup faster for positions near POS (but perhaps slower
for positions far away from POS). */)
(Lisp_Object pos)
{
-#ifndef NEW_OVERLAYS
ptrdiff_t p;
CHECK_NUMBER_COERCE_MARKER (pos);
p = clip_to_bounds (PTRDIFF_MIN, XINT (pos), PTRDIFF_MAX);
recenter_overlay_lists (current_buffer, p);
-#endif
return Qnil;
}
\f
@@ -5376,13 +5141,9 @@ init_buffer_once (void)
bset_mark_active (&buffer_defaults, Qnil);
bset_file_format (&buffer_defaults, Qnil);
bset_auto_save_file_format (&buffer_defaults, Qt);
-#ifndef NEW_OVERLAYS
set_buffer_overlays_before (&buffer_defaults, NULL);
set_buffer_overlays_after (&buffer_defaults, NULL);
buffer_defaults.overlay_center = BEG;
-#else
- buffer_defaults.overlays_root = OVERLAYS_SENTINEL;
-#endif
XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8);
bset_truncate_lines (&buffer_defaults, Qnil);
diff --git a/src/buffer.h b/src/buffer.h
index 9b2d887..87b7cee 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -27,10 +27,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "character.h"
#include "lisp.h"
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
-extern struct Lisp_Overlay *OVERLAY_SENTINEL;
-#endif
-
INLINE_HEADER_BEGIN
/* Accessing the parameters of the current buffer. */
@@ -866,7 +862,6 @@ struct buffer
/* Non-zero whenever the narrowing is changed in this buffer. */
bool_bf clip_changed : 1;
-#ifndef NEW_OVERLAYS
/* List of overlays that end at or before the current center,
in order of end-position. */
struct Lisp_Overlay *overlays_before;
@@ -877,11 +872,7 @@ struct buffer
/* Position where the overlay lists are centered. */
ptrdiff_t overlay_center;
-#endif
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
- struct Lisp_Overlay *overlays_root;
-#endif
/* Changes in the buffer are recorded here for undo, and t means
don't record anything. This information belongs to the base
buffer of an indirect buffer. But we can't store it in the
@@ -1186,17 +1177,7 @@ set_buffer_intervals (struct buffer *b, INTERVAL i)
INLINE bool
buffer_has_overlays (void)
{
-#ifdef NEW_OVERLAYS
- bool ret = current_buffer->overlays_root != OVERLAY_SENTINEL;
-#else
- bool ret = current_buffer->overlays_before ||
- current_buffer->overlays_after;
-#ifdef BOTH_OVERLAYS
- eassert (ret == (current_buffer->overlays_root !=
- OVERLAY_SENTINEL));
-#endif
-#endif
- return ret;
+ return current_buffer->overlays_before || current_buffer->overlays_after;
}
/* Return character code of multi-byte form at byte position POS. If POS
@@ -1245,7 +1226,6 @@ buffer_window_count (struct buffer *b)
return b->window_count;
}
-#ifndef NEW_OVERLAYS
/* Overlays */
/* Return the marker that stands for where OV starts in the buffer. */
@@ -1266,7 +1246,6 @@ buffer_window_count (struct buffer *b)
#define OVERLAY_POSITION(P) \
(MARKERP (P) ? marker_position (P) : (emacs_abort (), 0))
-#endif
\f
/***********************************************************************
Buffer-local Variables
diff --git a/src/deps.mk b/src/deps.mk
index c6469e6..72f68ca 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -40,8 +40,7 @@ bidi.o:
globals.h $(config_h)
buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \
$(INTERVALS_H) blockinput.h atimer.h systime.h character.h ../lib/unistd.h \
- indent.h keyboard.h coding.h keymap.h frame.h lisp.h globals.h
- $(config_h) $(OVERLAYS_H)
+ indent.h keyboard.h coding.h keymap.h frame.h lisp.h globals.h $(config_h)
callint.o: callint.c window.h commands.h buffer.h keymap.h globals.h msdos.h \
keyboard.h dispextern.h systime.h coding.h composite.h lisp.h \
character.h $(config_h)
diff --git a/src/emacs.c b/src/emacs.c
index 9a85213..bb85733 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1425,7 +1425,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
syms_of_floatfns ();
syms_of_buffer ();
- syms_of_overlays ();
syms_of_bytecode ();
syms_of_callint ();
syms_of_casefiddle ();
diff --git a/src/insdel.c b/src/insdel.c
index e844274..4ad1074 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -27,7 +27,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "intervals.h"
#include "character.h"
#include "buffer.h"
-#include "overlays.h"
#include "window.h"
#include "region-cache.h"
@@ -841,10 +840,6 @@ insert_1_both (const char *string,
PT + nchars, PT_BYTE + nbytes,
before_markers);
- overlay_tree_adjust_for_insert(current_buffer->overlays_root, PT, PT
- + nchars, PT_BYTE, PT_BYTE + nbytes,
- before_markers);
-
offset_intervals (current_buffer, PT, nchars);
if (!inherit && buffer_intervals (current_buffer))
@@ -971,12 +966,6 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
PT_BYTE + outgoing_nbytes,
before_markers);
- overlay_tree_adjust_for_insert(current_buffer->overlays_root, PT,
- PT + nchars, PT_BYTE,
- PT_BYTE + outgoing_nbytes,
- before_markers);
-
-
offset_intervals (current_buffer, PT, nchars);
intervals = string_intervals (string);
@@ -1031,12 +1020,6 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool text_at_gap_tail)
adjust_markers_for_insert (ins_charpos, ins_bytepos,
ins_charpos + nchars, ins_bytepos + nbytes, 0);
- overlay_tree_adjust_for_insert(current_buffer->overlays_root,
- ins_charpos, ins_charpos + nchars
- , ins_bytepos, ins_bytepos + nbytes,
- 0);
-
-
if (buffer_intervals (current_buffer))
{
offset_intervals (current_buffer, ins_charpos, nchars);
@@ -1180,11 +1163,6 @@ insert_from_buffer_1 (struct buffer *buf,
PT_BYTE + outgoing_nbytes,
0);
- overlay_tree_adjust_for_insert(current_buffer->overlays_root, PT, PT
- + nchars, PT_BYTE,
- PT_BYTE + outgoing_nbytes, 0);
-
-
offset_intervals (current_buffer, PT, nchars);
/* Get the intervals for the part of the string we are inserting. */
@@ -1235,22 +1213,11 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
if (nchars_del > 0)
- {
- adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
- len, len_byte);
- overlay_tree_adjust_for_replace(current_buffer->overlays_root,
- from, from_byte, nchars_del,
- nbytes_del, len, len_byte);
- }
+ adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
+ len, len_byte);
else
- {
- adjust_markers_for_insert (from, from_byte,
- from + len, from_byte + len_byte, 0);
- overlay_tree_adjust_for_insert(current_buffer->overlays_root,
- from, from + len, from_byte,
- from_byte + len_byte, 0);
- }
-
+ adjust_markers_for_insert (from, from_byte,
+ from + len, from_byte + len_byte, 0);
if (nchars_del > 0)
record_delete (from, prev_text, false);
@@ -1428,14 +1395,8 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
/* Adjust markers for the deletion and the insertion. */
if (markers)
- {
- adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
- inschars, outgoing_insbytes);
- overlay_tree_adjust_for_replace (current_buffer->overlays_root,
- from, from_byte, nchars_del,
- nbytes_del, inschars,
- outgoing_insbytes);
- }
+ adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
+ inschars, outgoing_insbytes);
/* Adjust the overlay center as needed. This must be done after
adjusting the markers that bound the overlays. */
@@ -1549,15 +1510,9 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
/* Adjust markers for the deletion and the insertion. */
if (markers
- && ! (nchars_del == 1 && inschars == 1 && nbytes_del ==
- insbytes))
- {
- adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
- inschars, insbytes);
- overlay_tree_adjust_for_replace (current_buffer->overlays_root,
- from, from_byte, nchars_del,
- nbytes_del, inschars, insbytes);
- }
+ && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes))
+ adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
+ inschars, insbytes);
/* Adjust the overlay center as needed. This must be done after
adjusting the markers that bound the overlays. */
@@ -1759,8 +1714,6 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
/* Relocate all markers pointing into the new, larger gap to point
at the end of the text before the gap. */
adjust_markers_for_delete (from, from_byte, to, to_byte);
- overlay_tree_adjust_for_delete(current_buffer->overlays_root, from,
- from_byte, to, to_byte);
MODIFF++;
CHARS_MODIFF = MODIFF;
diff --git a/src/lisp.h b/src/lisp.h
index d5cbec6..e0eb52a 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2112,30 +2112,11 @@ struct Lisp_Overlay
{
ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */
bool_bf gcmarkbit : 1;
-
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
- bool_bf start_insertion_type : 1;
- bool_bf end_insertion_type : 1;
- unsigned spacer : 13;
-#else
unsigned spacer : 15;
-#endif
-
struct Lisp_Overlay *next;
Lisp_Object start;
Lisp_Object end;
Lisp_Object plist;
-
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
- ptrdiff_t char_start, char_end;
- ptrdiff_t byte_start, byte_end;
- ptrdiff_t max;
-
- /* For the tree. */
- Lisp_Object parent; /* buffer or parent node */
- struct Lisp_Overlay *left, *right;
- unsigned level;
-#endif
};
/* Types of data which may be saved in a Lisp_Save_Value. */
@@ -3984,10 +3965,7 @@ extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t);
extern void adjust_overlays_for_delete (ptrdiff_t, ptrdiff_t);
extern void fix_start_end_in_overlays (ptrdiff_t, ptrdiff_t);
extern void report_overlay_modification (Lisp_Object, Lisp_Object, bool,
- Lisp_Object, Lisp_Object,
- Lisp_Object);
-
-
+ Lisp_Object, Lisp_Object, Lisp_Object);
extern bool overlay_touches_p (ptrdiff_t);
extern Lisp_Object other_buffer_safely (Lisp_Object);
extern Lisp_Object get_truename_buffer (Lisp_Object);
@@ -3996,10 +3974,6 @@ extern void init_buffer (int);
extern void syms_of_buffer (void);
extern void keys_of_buffer (void);
-/* Defined in overlay.c */
-
-extern void syms_of_overlays(void);
-
/* Defined in marker.c. */
extern ptrdiff_t marker_position (Lisp_Object);
diff --git a/src/overlays.c b/src/overlays.c
deleted file mode 100644
index c60a887..0000000
--- a/src/overlays.c
+++ /dev/null
@@ -1,800 +0,0 @@
-/*
- * Copyright (C) 2016 Joakim Jalap
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* This file implements an Arne Andersson-tree (AA-tree) for buffer
- overlays. It is an augmented interval tree. Basically each node
- has an interval and a 'max' value, which is the largest upper
- interval bound which appears in the subtree rooted in the node.
-
- The implementation of the tree functions is written as closely as
- possible to the one presented in Anderssons paper (REF)[1], but with a
- few differences. The code in [1] is written in Pascal, which has
- proper pass by reference. Unfortunately C doesn't really have this;
- this is the reason for passing around pointers to pointers.
-
- Also this tree has parent references, and the code in the delete
- routine is a bit more complicated because we need to delete the
- actual memory area, so as to not trip up the GC.
-
- The fact that this is an augmented tree also makes the rebalancing
- operation (split and skew) a bit more complex.
- */
-#include "overlays.h"
-#include "buffer.h"
-
-extern void
-modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t);
-
-/* Return the max of a, b and c. */
-static inline ptrdiff_t
-overlay_max (ptrdiff_t a, ptrdiff_t b, ptrdiff_t c)
-{
- ptrdiff_t bc_max = max(b, c);
- return max(a, bc_max);
-}
-
-/* Find what the max value should be for X. */
-static inline ptrdiff_t
-overlay_find_max (struct Lisp_Overlay *x)
-{
- return overlay_max(x->left->max, x->right->max, x->char_end);
-}
-
-/* The sentinel node. This indicates the bottom of the tree. It is
- basically a way to avoid having to check for NULL pointers all the
- time. */
-struct Lisp_Overlay OVERLAY_SENTINEL_NODE =
- {
- Lisp_Misc_Overlay, /* type */
- 1, /* gcmarkbit */
- 0, /* start_insertion_type */
- 0, /* end_insertion_type */
- 0, /* spacer */
- NULL, /* next */
- 0, /* start */
- 0, /* end */
- 0, /* plist */
- 0, /* char_start */
- 0, /* char_end */
- 0, /* byte_start */
- 0, /* byte_end */
- 0, /* max */
- 0, /* parent */
- &OVERLAY_SENTINEL_NODE, /* left */
- &OVERLAY_SENTINEL_NODE, /* right */
- 0 /* level */
- };
-
-struct Lisp_Overlay * OVERLAY_SENTINEL = &OVERLAY_SENTINEL_NODE;
-
-/* This function determines where overlays are inserted in the tree.
- FIXME: I didn't think too hard about this...
-*/
-static inline bool
-overlay_lt (struct Lisp_Overlay *a, struct Lisp_Overlay *b)
-{
- if (a->char_start < b->char_start)
- return true;
- else if (a->char_start > b->char_start)
- return false;
-
- if (a->char_end < b->char_end)
- return true;
- else if (a->char_end > b->char_end)
- return false;
-
- return false;
-}
-
-/* Rebalancing. See Andersson's paper for a good explaination. This
- is a bit more complicated than his code, since we need to maintain
- parent pointer and max field.
-*/
-inline static void
-overlay_skew (struct Lisp_Overlay **tt)
-{
- struct Lisp_Overlay *t = *tt;
- if (t->left->level == t->level && t != OVERLAY_SENTINEL)
- {
- struct Lisp_Overlay *tmp = t;
- t = *tt = t->left;
- tmp->left = t->right;
- t->right = tmp;
-
- tmp->max = overlay_find_max(tmp);
- t->max = overlay_find_max(t);
-
- t->parent = tmp->parent;
- XSETMISC (tmp->parent, t);
- if (tmp->left != OVERLAY_SENTINEL)
- XSETMISC (tmp->left->parent, tmp);
- }
-}
-
-/* Rebalancing. See Andersson's paper for a good explaination. This
- is a bit more complicated than his code, since we need to maintain
- parent pointer and max field.
-*/
-inline static void
-overlay_split (struct Lisp_Overlay **tt)
-{
- struct Lisp_Overlay *t = *tt;
- if (t->level == t->right->right->level && t != OVERLAY_SENTINEL)
- {
- struct Lisp_Overlay *tmp = t;
- t = *tt = t->right;
- tmp->right = t->left;
- t->left = tmp;
- t->level++;
-
- tmp->max = overlay_find_max(tmp);
- t->max = overlay_find_max(t);
-
- t->parent = tmp->parent;
- XSETMISC (tmp->parent, t);
- }
-}
-
-/* Insert NODE in TREE. When it is inserted, set its parent to
- PARENT. On the way up after the insertion, adjust the max field of
- each node if needed.
- */
-static ptrdiff_t
-overlay_tree_insert_internal (struct Lisp_Overlay **tree,
- struct Lisp_Overlay *parent,
- struct Lisp_Overlay *node)
-{
- struct Lisp_Overlay *t = *tree;
- if (t == OVERLAY_SENTINEL)
- {
- node->left = node->right = OVERLAY_SENTINEL;
- node->level = 1;
- node->max = node->char_end;
- XSETMISC (node->parent, parent);
- *tree = node;
- return node->max;
- }
- else
- {
- struct Lisp_Overlay **dir = overlay_lt (node, t) ?
- &t->left : &t->right;
-
- ptrdiff_t child_max = overlay_tree_insert_internal(dir, t, node);
- if (child_max > t->max)
- t->max = child_max;
- }
- overlay_skew (&t);
- overlay_split (&t);
- return t->max;
-}
-
-/* Insert NODE into TREE.
- */
-void
-overlay_tree_insert (struct Lisp_Overlay **tree,
- struct Lisp_Overlay *node)
-{
- overlay_tree_insert_internal(tree, *tree, node);
-}
-
-/* Delete NODE from TREE.
- */
-void
-overlay_tree_delete (struct Lisp_Overlay **tree,
- struct Lisp_Overlay *node)
-{
- struct Lisp_Overlay *t = *tree;
- static __thread struct Lisp_Overlay *last, *deleted;
-
- if (t == OVERLAY_SENTINEL)
- return;
-
- last = t;
- if (overlay_lt(node, t))
- overlay_tree_delete (&t->left, node);
- else
- {
- deleted = t;
- overlay_tree_delete (&t->right, node);
- }
-
-
- if (t == last &&
- deleted != OVERLAY_SENTINEL &&
- node == deleted)
- {
- last->left = deleted->left;
- last->right = deleted->right;
-
- if (BUFFERP (deleted->parent))
- {
- struct buffer *b = XBUFFER (deleted->parent);
- if (last == deleted)
- {
- b->overlays_root = OVERLAY_SENTINEL;
- }
- else
- {
- b->overlays_root = last;
- last->parent = deleted->parent;
- }
- }
- else
- {
- eassert (OVERLAYP (deleted->parent));
- struct Lisp_Overlay *up = XOVERLAY (deleted->parent);
- eassert (up->left == deleted || up->right == deleted);
- if (up->left == deleted)
- up->left = last == deleted ? OVERLAY_SENTINEL
- : last;
- else
- up->right = last == deleted ? OVERLAY_SENTINEL
- : last;
-
- XSETMISC (last->parent, up);
- }
- deleted->parent = Qnil;
- }
- else if (t->left->level < t->level - 1
- || t->right->level < t->level - 1)
- {
- t->level--;
- if (t->right->level > t->level)
- t->right->level = t->level;
-
- /* Andersson leaves it as 'an exercise for the reader' to prove
- that these rebalancing operions are enough. Don't you just love
- when that happens? */
- overlay_skew (&t);
- overlay_skew (&t->right);
- overlay_skew (&t->right->right);
- overlay_split (&t);
- overlay_split (&t->right);
- }
-}
-
-static void
-overlay_tree_drop_all_internal (struct buffer *buf,
- struct Lisp_Overlay *tree)
-{
- if (tree == OVERLAY_SENTINEL)
- return;
- overlay_tree_drop_all_internal (buf, tree->left);
- overlay_tree_drop_all_internal (buf, tree->right);
- modify_overlay (buf, tree->char_start, tree->char_end);
-}
-
-void
-overlay_tree_drop_all(struct buffer *buf)
-{
- overlay_tree_drop_all_internal (buf, buf->overlays_root);
- buf->overlays_root = OVERLAY_SENTINEL;
-}
-
-/* Add ELM to VECP at IDX. VECP has size VEC_SIZE. If IDX is at the
- end of VECP, realloc VECP and update VEC_SIZE.
- */
-static inline void
-add_to_vec (ptrdiff_t *vec_size, Lisp_Object **vecp,
- ptrdiff_t* idx, struct Lisp_Overlay *elm)
-{
- if (*idx == *vec_size - 1)
- {
- *vec_size += 50;
- *vecp = xnrealloc (*vecp, *vec_size, sizeof (Lisp_Object));
- }
-
- XSETMISC((*vecp)[(*idx)++], elm);
-}
-
-
-/* Add all nodes in TREE to VEC_PTR, which has size VEC_SIZE, starting
- from IDX. The nodes will be added in the order they have in the
- tree.
- */
-static void
-overlay_tree_all_internal (struct Lisp_Overlay *tree,
- ptrdiff_t *vec_size,
- Lisp_Object **vec_ptr,
- ptrdiff_t *idx)
-{
- if (tree == OVERLAY_SENTINEL)
- return;
-
- overlay_tree_all_internal (tree->left, vec_size,
- vec_ptr, idx);
- add_to_vec (vec_size, vec_ptr, idx, tree);
- overlay_tree_all_internal (tree->right, vec_size,
- vec_ptr, idx);
-}
-
-/* Put all nodes from TREE into VEC_PTR, adjusting VEC_SIZE as
- necessary.
- */
-ptrdiff_t
-overlay_tree_all (struct Lisp_Overlay *tree, ptrdiff_t *vec_size,
- Lisp_Object **vec_ptr)
-{
- ptrdiff_t n = 0;
- overlay_tree_all_internal (tree, vec_size, vec_ptr, &n);
- return n;
-}
-
-/* Add all nodes in TREE which contain POS to VEC_PTR at IDX.
- VEC_SIZE will be adjusted.
- */
-static void
-overlay_tree_at_internal (struct Lisp_Overlay *tree, ptrdiff_t pos,
- ptrdiff_t *vec_size, Lisp_Object **vec_ptr,
- ptrdiff_t *idx, ptrdiff_t *prev_ptr)
-{
- /* We are at a leaf. */
- if (tree == OVERLAY_SENTINEL)
- return;
-
- /* There's no subtree under here which can contain POS. Note
- tree->max, as this might be the closest before. */
- if (tree->max < pos)
- {
- if (tree->max > *prev_ptr)
- *prev_ptr = tree->max;
- return;
- }
-
-
- overlay_tree_at_internal (tree->left, pos, vec_size, vec_ptr,
- idx, prev_ptr);
-
- if (pos >= tree->char_start && pos <= tree->char_end)
- add_to_vec (vec_size, vec_ptr, idx, tree);
-
- /* If we are after POS, so are all the nodes to the right of us. */
- if (tree->char_start <= pos)
- overlay_tree_at_internal (tree->right, pos, vec_size, vec_ptr,
- idx, prev_ptr);
-}
-
-
-/* Find all nodes in TREE which contain POS and put them in VEC_PTR,
- growing it as necessary. The size of the vector VEC_PTR will be
- stored in VEC_SIZE. Return how many nodes were actually put in
- VEC_PTR.
- */
-ptrdiff_t
-overlay_tree_at (struct Lisp_Overlay *tree, ptrdiff_t pos,
- ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr,
- ptrdiff_t *vec_size, Lisp_Object **vec_ptr,
- bool chane_req)
-{
- ptrdiff_t idx = 0;
- ptrdiff_t max_before = 0;
-
- /* Due to the recursion order in `overlay_tree_at_internal' the
- overlays are sorted by their `char_start' in VEC_PTR. */
- overlay_tree_at_internal (tree, pos, vec_size, vec_ptr,
- &idx, &max_before);
-
- if (prev_ptr && max_before)
- *prev_ptr = max_before;
- else
- *prev_ptr = BEGV;
-
- /* If NEXT_PTR is not NULL, it should be set to the start_char of
- the leftmost descendant of the right child of the last element in
- VEC_PTR, or ZV if the right child is OVERLAY_SENTINEL. */
- if (next_ptr && idx)
- {
- struct Lisp_Overlay *last = XOVERLAY ((*vec_ptr)[idx - 1]);
- if (last->right != OVERLAY_SENTINEL)
- {
- last = last->right;
- while (last->left != OVERLAY_SENTINEL)
- last = last->left;
- *next_ptr = last->char_start;
- }
- else
- *next_ptr = ZV;
- }
-
- /* IDX points one behind the last element, so it is the size */
- return idx;
-}
-
-static inline void
-add_entry_to_vec (ptrdiff_t *vec_size, struct overlay_entry **vecp,
- ptrdiff_t* idx, Lisp_Object overlay,
- Lisp_Object str, bool after_p)
-{
- if (*idx == *vec_size - 1)
- {
- *vec_size += 50;
- *vecp = xnrealloc (*vecp, *vec_size,
- sizeof (struct overlay_entry));
- }
-
- Lisp_Object priority = Foverlay_get ((OVERLAY), Qpriority);
- EMACS_INT prio = INTEGERP (priority) ? XINT (priority) : 0;
-
-#define SET_ENTRY(ENT, ELM) (*vecp)[*idx].ENT = (ELM)
- SET_ENTRY(string, str);
- SET_ENTRY(overlay, overlay);
- SET_ENTRY(priority, prio);
- SET_ENTRY(after_string, after_p);
-#undef SET_ENTRY
-
- (*idx)++;
-}
-
-ptrdiff_t
-overlay_tree_load_overlays (struct Lisp_Overlay *tree, ptrdiff_t pos,
- ptrdiff_t *vec_size, ptrdiff_t **vec_ptr,
- ptridff_t *idx, struct window *w)
-{
- Lisp_Object window, invisible, str, ov;
- int invis;
-
- eassert (*idx == 0);
-
- if (tree == OVERLAY_SENTINEL || tree->max > pos)
- return;
-
- if (tree->char_start != pos && tree->char_end != pos)
- goto cont;
-
- window = lookup_char_property (tree->plist, Qwindow, 0);
- if (WINDOWP (window) && XWINDOW (window) != it->w)
- goto cont;
-
- invisible = lookup_char_property (tree->plist, Qinvisible, 0);
- invis = TEXT_PROP_MEANS_INVISIBLE (invisible);
-
- if ((tree->char_start == pos || (tree->char_end == pos && invis))
- && (str = lookup_char_property (tree->plist, Qbefore_string, 0),
- STRINGP (str))
- && SCHARS (str))
- {
- XSETMISC (ov, tree);
- add_entry_to_vec(vec_size, vec_ptr, idx, ov, str, false);
- }
-
- if ((tree->char_end == pos || (tree->char_start == pos && invis))
- && (str = lookup_char_property (tree->plist, Qafter_string, 0),
- STRINGP (str))
- && SCHARS (str))
- {
- XSETMISC (ov, tree);
- add_entry_to_vec(vec_size, vec_ptr, idx, ov, str, true);
- }
-
-
- cont:
- overlay_tree_load_overlays(tree->left, pos, vec_size, vec_ptr, w);
- if (tree->char_start <= pos)
- overlay_tree_load_overlays(tree->right, pos, vec_size, vec_ptr, w);
-}
-
-/* Return the buffer OVERLAY is in or nil if OVERLAY has been
- deleted. */
-Lisp_Object
-buffer_of_overlay (Lisp_Object overlay)
-{
- Lisp_Object o = overlay;
- while (!NILP (XOVERLAY (o)->parent) &&
- !BUFFERP (XOVERLAY (o)->parent))
- {
- eassert (OVERLAYP (XOVERLAY (o)->parent));
- eassert (XOVERLAY (XOVERLAY (o)->parent) != XOVERLAY (o));
-
- o = XOVERLAY (o)->parent;
- }
- return XOVERLAY (o)->parent;
-}
-
-void
-overlay_tree_zero_size_at (struct Lisp_Overlay *tree, ptrdiff_t pos,
- Lisp_Object hit_list)
-{
- if (tree == OVERLAY_SENTINEL || tree->max < pos)
- return;
-
- if (tree->char_start == pos && tree->char_end == pos)
- {
- Lisp_Object ov;
- XSETMISC (ov, tree);
- Fcons(hit_list, ov);
- }
-
- overlay_tree_zero_size_at (tree->right, pos, hit_list);
- if (pos >= tree->char_start)
- overlay_tree_zero_size_at (tree->left, pos, hit_list);
-}
-
-/* Adjust CHARPOS asn BYTEPOS for an insert from FROM_CHAR (FROM_BYTE)
- to TO_CHAR (TO_BYTE).
- FIXME: insertion_type and before.
- */
-static void
-adjust_pos_for_insert (ptrdiff_t *charpos, ptrdiff_t *bytepos,
- ptrdiff_t from_char, ptrdiff_t to_char,
- ptrdiff_t from_byte, ptrdiff_t to_byte,
- bool insertion_type , bool before)
-{
- if (*bytepos > from_byte)
- {
- *bytepos += to_byte - from_byte;
- *charpos += to_char - from_char;
- }
- else if (*bytepos == from_byte && insertion_type)
- {
- *bytepos = to_byte;
- *charpos = to_char;
- }
-}
-
-/* Adjust all nodes in TREE for an insert from FROM_CHAR (FROM_BYTE)
- to TO_CHAR (TO_BYTE). Return TREEs max.
- FIXME: before.
- */
-ptrdiff_t
-overlay_tree_adjust_for_insert (struct Lisp_Overlay *tree,
- ptrdiff_t from_char,
- ptrdiff_t to_char,
- ptrdiff_t from_byte,
- ptrdiff_t to_byte,
- bool before)
-{
- /* If we are at a leaf or all nodes in TREE are before the insert,
- return. */
- if (tree == OVERLAY_SENTINEL || tree->max < from_char)
- return tree->max;
-
- /* Adjust the start postions. */
- adjust_pos_for_insert(&tree->char_start, &tree->byte_start, from_char,
- to_char, from_byte, to_byte,
- tree->start_insertion_type, before);
- /* Adjust the end postions. */
- adjust_pos_for_insert(&tree->char_end, &tree->byte_end, from_char,
- to_char, from_byte, to_byte,
- tree->end_insertion_type, before);
-
- ptrdiff_t r,l;
-
- l = overlay_tree_adjust_for_insert (tree->left, from_char,
- to_char, from_byte,
- to_byte, before);
- r = overlay_tree_adjust_for_insert (tree->right, from_char,
- to_char, from_byte,
- to_byte, before);
-
- tree->max = overlay_max(l, r, tree->char_end);
- return tree->max;
-}
-
-/* Adjust CHARPOS and BYTEPOS for a delete from FROM_CHAR (FROM_BYTE)
- to TO_CHAR (TO_BYTE).
- */
-static void
-adjust_pos_for_delete (ptrdiff_t *charpos, ptrdiff_t *bytepos,
- ptrdiff_t from_char, ptrdiff_t from_byte,
- ptrdiff_t to_char, ptrdiff_t to_byte)
-{
- if (*charpos > to_char)
- {
- *charpos = to_char - from_char;
- *bytepos = to_byte - from_byte;
- }
- else if (*charpos > from_char)
- {
- *charpos = from_char;
- *bytepos = from_byte;
- }
-}
-
-/* Adjust TREE for a delete from FROM_CHAR (FROM_BYTE) to TO_CHAR
- (TO_BYTE).
- */
-ptrdiff_t
-overlay_tree_adjust_for_delete (struct Lisp_Overlay *tree,
- ptrdiff_t from_char, ptrdiff_t from_byte,
- ptrdiff_t to_char, ptrdiff_t to_byte)
-{
- if (tree == OVERLAY_SENTINEL || tree->max < from_char)
- return tree->max;
-
- adjust_pos_for_delete(&tree->char_start, &tree->byte_start, from_char,
- from_byte, to_char, to_byte);
- adjust_pos_for_delete(&tree->char_end, &tree->byte_end, from_char,
- from_byte, to_char, to_byte);
-
- ptrdiff_t r, l;
-
- l = overlay_tree_adjust_for_delete(tree->left, from_char, from_byte,
- to_char, to_byte);
- r = overlay_tree_adjust_for_delete(tree->right, from_char, from_byte,
- to_char, to_byte);
-
- tree->max = overlay_max(l, r, tree->char_end);
- return tree->max;
-}
-
-/* Adjust CHARPOS and BYTEPOS for a delete from FROM_CHAR (FROM_BYTE)
- to TO_CHAR (TO_BYTE).
- */
-static void
-adjust_pos_for_replace (ptrdiff_t *charpos, ptrdiff_t *bytepos,
- ptrdiff_t from_char, ptrdiff_t from_byte,
- ptrdiff_t old_chars, ptrdiff_t old_bytes,
- ptrdiff_t new_chars, ptrdiff_t new_bytes)
-{
- ptrdiff_t diff_chars = new_chars - old_chars;
- ptrdiff_t diff_bytes = new_bytes - old_bytes;
-
- if (*bytepos >= (from_byte + old_bytes))
- {
- *charpos += diff_chars;
- *bytepos += diff_bytes;
- }
- else if (*bytepos > from_byte)
- {
- *charpos = from_char;
- *bytepos = from_byte;
- }
-}
-
-/* Adjust TREE for a delete from FROM_CHAR (FROM_BYTE)
- to TO_CHAR (TO_BYTE).
- */
-ptrdiff_t
-overlay_tree_adjust_for_replace (struct Lisp_Overlay *tree,
- ptrdiff_t from_char,
- ptrdiff_t from_byte,
- ptrdiff_t old_chars,
- ptrdiff_t old_bytes,
- ptrdiff_t new_chars,
- ptrdiff_t new_bytes)
-{
- if (tree == OVERLAY_SENTINEL || tree->max <= from_byte)
- return tree->max;
-
- adjust_pos_for_replace(&tree->char_start, &tree->byte_start,
- from_char, from_byte, old_chars, old_bytes,
- new_chars, new_bytes);
- adjust_pos_for_replace(&tree->char_end, &tree->byte_end,
- from_char, from_byte, old_chars, old_bytes,
- new_chars, new_bytes);
-
- ptrdiff_t r, l;
-
- l = overlay_tree_adjust_for_replace(tree->left, from_char,
- from_byte, old_chars,
- old_bytes, new_chars,
- new_bytes);
- r = overlay_tree_adjust_for_replace(tree->right, from_char,
- from_byte, old_chars,
- old_bytes, new_chars,
- new_bytes);
-
- tree->max = overlay_max(l, r, tree->char_end);
- return tree->max;
-}
-
-
-DEFUN("overlay-parent", Foverlay_parent, Soverlay_parent, 1, 1, 0,
- doc: /* Parent of overlay. An overlay or a buffer. */)
- (Lisp_Object overlay)
-{
- if (!OVERLAYP(overlay))
- signal_error("Not an overlay", Qnil);
- return XOVERLAY (overlay)->parent;
-}
-
-DEFUN("overlay-info", Foverlay_info, Soverlay_info, 1, 1, 0,
- doc: /* Info about OVERLAY. */)
- (Lisp_Object overlay)
-{
- if (!OVERLAYP(overlay))
- signal_error("Not an overlay", Qnil);
- Lisp_Object ret;
- struct Lisp_Overlay *o = XOVERLAY (overlay);
- Lisp_Object left, right, this;
- if (o->left != OVERLAY_SENTINEL)
- XSETMISC(left, o->left);
- else
- left = Qt;
-
- if (o->right != OVERLAY_SENTINEL)
- XSETMISC(right, o->right);
- else
- right = Qt;
-
- XSETMISC (this, o);
-
- ret = list5(Fcons(Fcons(make_number(o->char_start),
- make_number(o->char_end)),
- make_number(o->max)),
- this,
- o->parent,
- make_number (o->level),
- Fcons(left,
- right));
- return ret;
-}
-
-DEFUN("overlays-in-buffer", Foverlays_in_buffer, Soverlays_in_buffer,
- 0, 1, 0,
- doc: /* Return a list of all the overlays in BUFFER. */)
- (Lisp_Object buffer)
-{
- Lisp_Object ret;
- struct buffer *b;
- if (!NILP (buffer))
- b = XBUFFER (buffer);
- else
- b = current_buffer;
-
-
- ptrdiff_t vec_size = 30;
- Lisp_Object *vec = xnmalloc (vec_size, sizeof (Lisp_Object));
-
-
- ptrdiff_t noverlays = overlay_tree_all(b->overlays_root,
- &vec_size, &vec);
- ret = Flist(noverlays, vec);
-
- return ret;
-}
-
-DEFUN("overlay-tree-at", Foverlay_tree_at, Soverlay_tree_at,
- 1, 2, 0,
- doc: /* Return a list of all overlays in BUFFER. If BUFFER is
- nil, use the current buffer. */)
- (Lisp_Object pos, Lisp_Object buffer)
-{
- CHECK_NUMBER_COERCE_MARKER (pos);
-
- ptrdiff_t next, prev;
- ptrdiff_t bufpos = XINT (pos);
-
- Lisp_Object ret;
- struct buffer *b;
- if (!NILP (buffer))
- b = XBUFFER (buffer);
- else
- b = current_buffer;
-
-
- ptrdiff_t vec_size = 30;
- Lisp_Object *vec = xnmalloc (vec_size, sizeof (Lisp_Object));
-
-
- ptrdiff_t noverlays = overlay_tree_at(b->overlays_root, bufpos,
- &next, &prev,
- &vec_size, &vec, false);
-
- ret = Flist(noverlays, vec);
-
- return ret;
-}
-
-void
-syms_of_overlays (void)
-{
- defsubr (&Soverlay_parent);
- defsubr (&Soverlay_info);
- defsubr (&Soverlays_in_buffer);
- defsubr (&Soverlay_tree_at);
-}
diff --git a/src/overlays.h b/src/overlays.h
deleted file mode 100644
index d5d85a9..0000000
--- a/src/overlays.h
+++ /dev/null
@@ -1,75 +0,0 @@
-
-#ifndef OVERLAYS_H
-#define OVERLAYS_H
-
-#include <config.h>
-#include "lisp.h"
-
-extern struct Lisp_Overlay OVERLAY_SENTINEL_NODE;
-
-extern struct Lisp_Overlay * OVERLAY_SENTINEL;
-
-struct overlay_entry
-{
- Lisp_Object overlay;
- Lisp_Object string;
- EMACS_INT priority;
- bool after_string_p;
-};
-
-void
-overlay_tree_insert (struct Lisp_Overlay **tree,
- struct Lisp_Overlay *node);
-
-void
-overlay_tree_delete (struct Lisp_Overlay **tree,
- struct Lisp_Overlay *node);
-
-void
-overlay_tree_drop_all (struct buffer *buf);
-
-Lisp_Object
-buffer_of_overlay (Lisp_Object overlay);
-
-ptrdiff_t
-overlay_tree_all (struct Lisp_Overlay *tree, ptrdiff_t *vec_size,
- Lisp_Object **vec_ptr);
-
-ptrdiff_t
-overlay_tree_at (struct Lisp_Overlay *tree, ptrdiff_t pos,
- ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr,
- ptrdiff_t *vec_size, Lisp_Object **vec_ptr,
- bool chane_req);
-
-void
-overlay_tree_zero_size_at (struct Lisp_Overlay *tree, ptrdiff_t pos,
- Lisp_Object hit_list);
-
-ptrdiff_t
-overlay_tree_adjust_for_insert (struct Lisp_Overlay *tree,
- ptrdiff_t from_char,
- ptrdiff_t to_char,
- ptrdiff_t from_byte,
- ptrdiff_t to_byte,
- bool before);
-
-ptrdiff_t
-overlay_tree_adjust_for_delete (struct Lisp_Overlay *tree,
- ptrdiff_t from_char, ptrdiff_t from_byte,
- ptrdiff_t to_char, ptrdiff_t to_byte);
-
-ptrdiff_t
-overlay_tree_adjust_for_replace (struct Lisp_Overlay *tree,
- ptrdiff_t from_char,
- ptrdiff_t from_byte,
- ptrdiff_t old_chars,
- ptrdiff_t old_bytes,
- ptrdiff_t new_chars,
- ptrdiff_t new_bytes);
-
-ptrdiff_t
-overlay_tree_at (struct Lisp_Overlay *tree, Lisp_Object **vecp,
- ptrdiff_t pos);
-
-
-#endif /* OVERLAYS_H */
diff --git a/src/xdisp.c b/src/xdisp.c
index 785853e..1289515 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -315,9 +315,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "fontset.h"
#include "blockinput.h"
#include "xwidget.h"
-#if defined(NEW_OVERLAYS) || defined(BOTH_OVERLAYS)
-#include "overlays.h"
-#endif
#ifdef HAVE_WINDOW_SYSTEM
#include TERM_HEADER
#endif /* HAVE_WINDOW_SYSTEM */
@@ -5502,7 +5499,7 @@ handle_composition_prop (struct it *it)
/* The following structure is used to record overlay strings for
later sorting in load_overlay_strings. */
-#if !defined(NEW_OVERLAYS) && !defined(BOTH_OVERLAYS)
+
struct overlay_entry
{
Lisp_Object overlay;
@@ -5510,7 +5507,7 @@ struct overlay_entry
EMACS_INT priority;
bool after_string_p;
};
-#endif
+
/* Set up iterator IT from overlay strings at its current position.
Called from handle_stop. */
@@ -5712,7 +5709,6 @@ load_overlay_strings (struct it *it, ptrdiff_t charpos)
if (charpos <= 0)
charpos = IT_CHARPOS (*it);
-#ifndef NEW_OVERLAYS
/* Append the overlay string STRING of overlay OVERLAY to vector
`entries' which has size `size' and currently contains `n'
elements. AFTER_P means STRING is an after-string of
@@ -5819,30 +5815,6 @@ load_overlay_strings (struct it *it, ptrdiff_t charpos)
}
#undef RECORD_OVERLAY_STRING
-#ifdef BOTH_OVERLAYS
- struct window *sw = XWINDOW (window);
- ptrdiff_t n1, ii, jj;
- struct overlay_entry entriesbuf1[20];
- ptrdiff_t size1 = ARRAYELTS (entriesbuf);
- overlay_tree_load_overlays (current_buffer->overlays_root,
- charpos, &size, &entries, &n, sw);
- eassert (n1 == n);
- for (ii = 0; ii < n; ii++) {
- bool found = false;
- struct overlay_entry *oe1 = &entries[ii];
- for (jj = 0; jj < n; jj++) {
- struct overlay_entry *oe2 = &entries1[jj];
- if (*oe1 == *oe2)
- found = true;
- }
- eassert (found);
- }
-#endif
-#else /* if NEW_OVERLAYS is defined */
- struct window *sw = XWINDOW (window);
- overlay_tree_load_overlays (current_buffer->overlays_root,
- charpos, &size, &entries, &n, sw);
-#endif
/* Sort entries. */
if (n > 1)
@@ -5868,7 +5840,6 @@ load_overlay_strings (struct it *it, ptrdiff_t charpos)
}
-
/* Get the first chunk of overlay strings at IT's current buffer
position, or at CHARPOS if that is > 0. Value is true if at
least one overlay string was found. */
diff --git a/test/lisp/overlay-tests.el b/test/lisp/overlay-tests.el
deleted file mode 100644
index 407aaee..0000000
--- a/test/lisp/overlay-tests.el
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-(require 'ert)
-
-(ert-deftest overlay-create-test ()
- " "
- (with-temp-buffer
- (insert "blueberrypancakes")
- (let ((o1 (make-overlay 4 9)))
- (should-not (overlay-get o1 'face))
- (should (overlayp o1))
- (should (= (overlay-start o1) 4))
- (should (= (overlay-end o1) 9))
- (should (eq (overlay-buffer o1) (current-buffer)))
- (let ((b (current-buffer)))
- (with-temp-buffer
- (should (eq (overlay-buffer o1) b))))
- (should (= (length (overlays-in (point-min) (point-max))) 1))
- (should (eq (car (overlays-in (point-min) (point-max))) o1)))))
-
-
-(ert-deftest overlay-move-test ()
- " "
- (with-temp-buffer
- (insert "blueberrypancakes")
- (let ((o1 (make-overlay 4 9)))
- ;; Test a "normal" move
- (should (= (overlay-start o1) 4))
- (should (= (overlay-end o1) 9))
- (should (eq (overlay-buffer o1) (current-buffer)))
- (move-overlay o1 3 10)
- (should (= (overlay-start o1) 3))
- (should (= (overlay-end o1) 10))
- (let ((b (current-buffer)))
- (with-temp-buffer
- (insert "blueberry")
- (move-overlay o1 2 4)
- (should (eq (overlay-buffer o1) b))
- (move-overlay o1 2 4 (current-buffer))
- (should (eq (overlay-buffer o1) (current-buffer)))
- (should (= (overlay-start o1) 2))
- (should (= (overlay-end o1) 4))))
- (move-overlay o1 1 50 (current-buffer))
- (should (eq (overlay-buffer o1) (current-buffer)))
- (should (= (overlay-start o1) 1))
- (should (= (overlay-end o1) (point-max))))))
-
-(ert-deftest overlay-front-advance-test ()
- (with-temp-buffer
- (insert "blueberrypancakes")
- (let ((o1 (make-overlay 1 5 nil t))
- (o2 (make-overlay 1 5))
- (str "creamy "))
- (goto-char (point-min))
- (insert str)
- (should (= (overlay-start o2) 1))
- (should (= (overlay-start o1) (1+ (length str)))))))
-
-(ert-deftest overlay-rear-advance-test ()
- (with-temp-buffer
- (insert "blueberrypancakes")
- (let ((o1 (make-overlay 7 18 nil nil t))
- (o2 (make-overlay 7 18))
- (str " for dinner"))
- (should (= (point-max) 18))
- (goto-char (point-max))
- (insert str)
- (should (= (overlay-end o1) (point-max)))
- (should (= (overlay-end o2) 18)))))
next prev parent reply other threads:[~2016-09-20 17:13 UTC|newest]
Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 10:32 Overlays as an AA-tree Joakim Jalap
2016-09-20 12:14 ` Clément Pit--Claudel
2016-09-20 12:43 ` Lars Ingebrigtsen
2016-09-20 16:19 ` Joakim Jalap
2016-09-20 23:19 ` Richard Stallman
2016-09-20 14:40 ` Eli Zaretskii
2016-09-20 17:13 ` Joakim Jalap [this message]
2016-09-21 16:14 ` Eli Zaretskii
2016-09-22 10:35 ` Joakim Jalap
2016-09-22 12:24 ` Stefan Monnier
2016-09-21 14:52 ` Stefan Monnier
2016-09-21 15:58 ` Eli Zaretskii
2016-09-21 16:24 ` Stefan Monnier
2016-09-21 16:43 ` Eli Zaretskii
2016-09-21 18:41 ` Stefan Monnier
2016-09-21 19:28 ` Eli Zaretskii
2016-09-22 10:35 ` Joakim Jalap
2016-09-22 12:17 ` Stefan Monnier
2016-09-22 20:11 ` Joakim Jalap
2016-09-23 1:29 ` Stefan Monnier
2016-09-27 6:26 ` Joakim Jalap
2016-09-27 11:50 ` Stefan Monnier
2016-09-27 14:38 ` Eli Zaretskii
2016-09-27 16:07 ` Joakim Jalap
2016-11-21 17:32 ` Clément Pit--Claudel
2016-11-22 8:09 ` Joakim Jalap
2016-11-22 13:44 ` Stefan Monnier
2016-11-23 6:58 ` Joakim Jalap
2016-11-22 13:44 ` Clément Pit--Claudel
2016-11-22 13:55 ` Evgeny Roubinchtein
2016-11-23 7:16 ` Joakim Jalap
2016-11-23 15:42 ` Eli Zaretskii
2016-11-23 16:06 ` Stefan Monnier
2016-11-24 18:33 ` Evgeny Roubinchtein
2016-11-23 7:13 ` Joakim Jalap
2017-02-03 8:49 ` Andreas Politz
2017-02-03 9:13 ` Eli Zaretskii
2017-02-03 10:24 ` Andreas Politz
2017-02-03 11:33 ` Joakim Jalap
2017-02-03 12:44 ` Andreas Politz
2017-02-03 14:11 ` Joakim Jalap
2017-02-03 15:02 ` Andreas Politz
2017-02-03 15:23 ` Joakim Jalap
2017-02-03 15:54 ` Andreas Politz
2017-02-04 21:22 ` Stefan Monnier
2017-02-04 23:10 ` Andreas Politz
2017-02-06 9:56 ` Joakim Jalap
2017-02-06 11:33 ` Andreas Politz
2017-02-06 15:33 ` Joakim Jalap
2017-02-06 15:46 ` Stefan Monnier
2017-02-06 16:52 ` Joakim Jalap
2017-02-06 17:34 ` Stefan Monnier
2017-02-06 17:32 ` Andreas Politz
2017-02-07 12:35 ` Andreas Politz
2017-02-07 14:46 ` Joakim Jalap
2017-02-07 22:00 ` Andreas Politz
2017-02-08 0:36 ` Andreas Politz
2017-02-08 6:53 ` Joakim Jalap
2017-02-08 7:34 ` Andreas Politz
2017-02-08 8:18 ` Joakim Jalap
2017-02-08 8:44 ` Andreas Politz
2017-02-08 16:34 ` Andreas Politz
2017-02-08 17:38 ` Eli Zaretskii
2017-02-08 13:04 ` Stefan Monnier
2017-02-08 22:27 ` Andreas Politz
2017-02-08 22:34 ` Stefan Monnier
2017-02-09 9:34 ` Andreas Politz
2017-02-09 10:05 ` Joakim Jalap
2017-02-09 10:19 ` Andreas Politz
2017-02-13 3:44 ` Andreas Politz
2017-02-13 6:11 ` Eli Zaretskii
2017-02-13 9:04 ` Andreas Politz
2017-02-13 14:36 ` Eli Zaretskii
2017-02-14 10:07 ` Andreas Politz
2017-02-17 4:58 ` Andreas Politz
2017-02-17 7:12 ` Eli Zaretskii
2017-02-19 22:39 ` Andreas Politz
2017-02-19 23:10 ` Stefan Monnier
2017-02-19 23:44 ` Andreas Politz
2017-02-20 15:34 ` Eli Zaretskii
2017-02-21 6:56 ` Andreas Politz
2017-02-21 15:11 ` Stefan Monnier
2017-02-21 18:26 ` Andreas Politz
2017-02-21 19:18 ` Stefan Monnier
2017-02-21 23:36 ` Andreas Politz
2017-02-24 8:43 ` Andreas Politz
2017-04-08 13:28 ` Clément Pit-Claudel
2017-05-03 19:20 ` Andreas Politz
2017-05-03 19:40 ` Stefan Monnier
2017-05-05 20:39 ` Andreas Politz
2017-05-04 0:54 ` Clément Pit-Claudel
2017-05-05 20:10 ` Andreas Politz
2017-05-05 22:22 ` Clément Pit-Claudel
2017-05-06 8:05 ` Andreas Politz
2017-05-04 14:21 ` Eli Zaretskii
2017-05-05 20:08 ` Andreas Politz
2017-05-05 21:41 ` Eli Zaretskii
2017-09-24 13:09 ` Clément Pit-Claudel
2017-10-04 8:17 ` Andreas Politz
2017-10-04 9:22 ` Eli Zaretskii
2017-10-04 20:36 ` Andreas Politz
2017-02-14 0:45 ` Richard Stallman
2017-02-14 8:32 ` Andreas Politz
2017-02-06 13:51 ` Stefan Monnier
2017-02-06 14:26 ` Andreas Politz
2017-02-06 15:06 ` Stefan Monnier
2017-02-06 15:40 ` Joakim Jalap
2017-02-06 16:24 ` Clément Pit-Claudel
2017-02-03 13:55 ` Stefan Monnier
2017-02-03 15:14 ` Andreas Politz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lgymjxz1.fsf@fastmail.com \
--to=joakim.jalap@fastmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.