Lisp_Object Qkill_buffer_hook;
+Lisp_Object Qoverlayp;
+
/* For debugging; temporary. See set_buffer_internal. */
/* Lisp_Object Qlisp_mode, Vcheck_symbol; */
/* Find all the overlays in the current buffer that contain position POS.
Return the number found, and store them in a vector in *VEC_PTR.
Store in *LEN_PTR the size allocated for the vector.
- Store in *NEXT_PTR the next position after POS where an overlay starts.
+ Store in *NEXT_PTR the next position after POS where an overlay starts,
+ or ZV if there are no more overlays.
*VEC_PTR and *LEN_PTR should contain a valid vector and size
when this function is called. */
int len = *len_ptr;
Lisp_Object *vec = *vec_ptr;
int next = ZV;
- int startpos;
-
for (tail = current_buffer->overlays_before;
CONSP (tail);
tail = XCONS (tail)->cdr)
{
+ int startpos;
+
overlay = XCONS (tail)->car;
if (! OVERLAY_VALID (overlay))
- continue;
+ abort ();
start = OVERLAY_START (overlay);
end = OVERLAY_END (overlay);
CONSP (tail);
tail = XCONS (tail)->cdr)
{
+ int startpos;
+
overlay = XCONS (tail)->car;
if (! OVERLAY_VALID (overlay))
- continue;
+ abort ();
start = OVERLAY_START (overlay);
end = OVERLAY_END (overlay);
startpos = OVERLAY_POSITION (start);
- if (startpos > pos)
+ if (pos < startpos)
{
if (startpos < next)
next = startpos;
break;
}
- if (OVERLAY_POSITION (end) > pos)
+ if (pos < OVERLAY_POSITION (end))
{
if (idx == len)
{
/* If the overlay is not valid, get rid of it. */
if (!OVERLAY_VALID (overlay))
+#if 1
+ abort ();
+#else
{
/* Splice the cons cell TAIL out of overlays_before. */
if (!NILP (prev))
tail = prev;
continue;
}
+#endif
beg = OVERLAY_START (overlay);
end = OVERLAY_END (overlay);
otheroverlay = XCONS (other)->car;
if (! OVERLAY_VALID (otheroverlay))
- continue;
+ abort ();
otherbeg = OVERLAY_START (otheroverlay);
if (OVERLAY_POSITION (otherbeg) >= where)
/* If the overlay is not valid, get rid of it. */
if (!OVERLAY_VALID (overlay))
+#if 1
+ abort ();
+#else
{
/* Splice the cons cell TAIL out of overlays_after. */
if (!NILP (prev))
tail = prev;
continue;
}
+#endif
beg = OVERLAY_START (overlay);
end = OVERLAY_END (overlay);
otheroverlay = XCONS (other)->car;
if (! OVERLAY_VALID (otheroverlay))
- continue;
+ abort ();
otherend = OVERLAY_END (otheroverlay);
if (OVERLAY_POSITION (otherend) <= where)
XFASTINT (buf->overlay_center) = pos;
}
\f
+DEFUN ("overlayp", Foverlayp, Soverlayp, 1, 1, 0,
+ "Return t if OBJECT is an overlay.")
+ (object)
+ Lisp_Object object;
+{
+ return (OVERLAYP (object) ? Qt : Qnil);
+}
+
DEFUN ("make-overlay", Fmake_overlay, Smake_overlay, 2, 3, 0,
"Create a new overlay with range BEG to END in BUFFER.\n\
If omitted, BUFFER defaults to the current buffer.\n\
end = Fset_marker (Fmake_marker (), end, buffer);
overlay = Fcons (Fcons (beg, end), Qnil);
+ XSETTYPE (overlay, Lisp_Overlay);
/* Put the new overlay on the wrong list. */
end = OVERLAY_END (overlay);
{
struct buffer *b;
- if (!OVERLAY_VALID (overlay))
- error ("Invalid overlay object");
-
+ CHECK_OVERLAY (overlay, 0);
if (NILP (buffer))
buffer = Fmarker_buffer (OVERLAY_START (overlay));
CHECK_BUFFER (buffer, 3);
-
CHECK_NUMBER_COERCE_MARKER (beg, 1);
CHECK_NUMBER_COERCE_MARKER (end, 1);
{
struct buffer *b;
- if (OVERLAY_VALID (overlay))
- b = XBUFFER (Fmarker_buffer (OVERLAY_START (overlay)));
- else
- /* Guess! */
- b = current_buffer;
+ CHECK_OVERLAY (overlay, 0);
+
+ b = XBUFFER (Fmarker_buffer (OVERLAY_START (overlay)));
b->overlays_before = Fdelq (overlay, b->overlays_before);
b->overlays_after = Fdelq (overlay, b->overlays_after);
+ Fset_marker (OVERLAY_START (overlay), 1, Qnil);
+ Fset_marker (OVERLAY_END (overlay), 1, Qnil);
+
redisplay_region (b,
OVERLAY_POSITION (OVERLAY_START (overlay)),
OVERLAY_POSITION (OVERLAY_END (overlay)));
Lisp_Object overlay, prop;
{
Lisp_Object plist;
- for (plist = Fcdr_safe (Fcdr_safe (overlay));
+
+ CHECK_OVERLAY (overlay, 0);
+
+ for (plist = Fcdr_safe (XCONS (overlay)->cdr);
CONSP (plist) && CONSP (XCONS (plist)->cdr);
plist = XCONS (XCONS (plist)->cdr)->cdr)
{
if (EQ (XCONS (plist)->car, prop))
return XCONS (XCONS (plist)->cdr)->car;
}
+
+ return Qnil;
}
DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
{
Lisp_Object plist, tail;
- if (!OVERLAY_VALID (overlay))
- error ("Invalid overlay object");
+ CHECK_OVERLAY (overlay, 0);
redisplay_region (XMARKER (OVERLAY_START (overlay))->buffer,
OVERLAY_POSITION (OVERLAY_START (overlay)),
OVERLAY_POSITION (OVERLAY_END (overlay)));
- plist = Fcdr_safe (Fcdr_safe (overlay));
+ plist = Fcdr_safe (XCONS (overlay)->cdr);
for (tail = plist;
CONSP (tail) && CONSP (XCONS (tail)->cdr);
staticpro (&Qprotected_field);
staticpro (&Qpermanent_local);
staticpro (&Qkill_buffer_hook);
+ staticpro (&Qoverlayp);
+
+ Qoverlayp = intern ("overlayp");
Fput (Qprotected_field, Qerror_conditions,
Fcons (Qprotected_field, Fcons (Qerror, Qnil)));
defsubr (&Slist_buffers);
defsubr (&Skill_all_local_variables);
+ defsubr (&Soverlayp);
defsubr (&Smake_overlay);
defsubr (&Sdelete_overlay);
defsubr (&Smove_overlay);