aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c72
1 files changed, 50 insertions, 22 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 3c7a4db577f..9e27460fb44 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -124,6 +124,8 @@ Lisp_Object QSFundamental; /* A string "Fundamental" */
124 124
125Lisp_Object Qkill_buffer_hook; 125Lisp_Object Qkill_buffer_hook;
126 126
127Lisp_Object Qoverlayp;
128
127/* For debugging; temporary. See set_buffer_internal. */ 129/* For debugging; temporary. See set_buffer_internal. */
128/* Lisp_Object Qlisp_mode, Vcheck_symbol; */ 130/* Lisp_Object Qlisp_mode, Vcheck_symbol; */
129 131
@@ -1196,7 +1198,8 @@ a non-nil `permanent-local' property are not eliminated by this function.")
1196/* Find all the overlays in the current buffer that contain position POS. 1198/* Find all the overlays in the current buffer that contain position POS.
1197 Return the number found, and store them in a vector in *VEC_PTR. 1199 Return the number found, and store them in a vector in *VEC_PTR.
1198 Store in *LEN_PTR the size allocated for the vector. 1200 Store in *LEN_PTR the size allocated for the vector.
1199 Store in *NEXT_PTR the next position after POS where an overlay starts. 1201 Store in *NEXT_PTR the next position after POS where an overlay starts,
1202 or ZV if there are no more overlays.
1200 1203
1201 *VEC_PTR and *LEN_PTR should contain a valid vector and size 1204 *VEC_PTR and *LEN_PTR should contain a valid vector and size
1202 when this function is called. */ 1205 when this function is called. */
@@ -1213,15 +1216,15 @@ overlays_at (pos, vec_ptr, len_ptr, next_ptr)
1213 int len = *len_ptr; 1216 int len = *len_ptr;
1214 Lisp_Object *vec = *vec_ptr; 1217 Lisp_Object *vec = *vec_ptr;
1215 int next = ZV; 1218 int next = ZV;
1216 int startpos;
1217
1218 for (tail = current_buffer->overlays_before; 1219 for (tail = current_buffer->overlays_before;
1219 CONSP (tail); 1220 CONSP (tail);
1220 tail = XCONS (tail)->cdr) 1221 tail = XCONS (tail)->cdr)
1221 { 1222 {
1223 int startpos;
1224
1222 overlay = XCONS (tail)->car; 1225 overlay = XCONS (tail)->car;
1223 if (! OVERLAY_VALID (overlay)) 1226 if (! OVERLAY_VALID (overlay))
1224 continue; 1227 abort ();
1225 1228
1226 start = OVERLAY_START (overlay); 1229 start = OVERLAY_START (overlay);
1227 end = OVERLAY_END (overlay); 1230 end = OVERLAY_END (overlay);
@@ -1246,20 +1249,22 @@ overlays_at (pos, vec_ptr, len_ptr, next_ptr)
1246 CONSP (tail); 1249 CONSP (tail);
1247 tail = XCONS (tail)->cdr) 1250 tail = XCONS (tail)->cdr)
1248 { 1251 {
1252 int startpos;
1253
1249 overlay = XCONS (tail)->car; 1254 overlay = XCONS (tail)->car;
1250 if (! OVERLAY_VALID (overlay)) 1255 if (! OVERLAY_VALID (overlay))
1251 continue; 1256 abort ();
1252 1257
1253 start = OVERLAY_START (overlay); 1258 start = OVERLAY_START (overlay);
1254 end = OVERLAY_END (overlay); 1259 end = OVERLAY_END (overlay);
1255 startpos = OVERLAY_POSITION (start); 1260 startpos = OVERLAY_POSITION (start);
1256 if (startpos > pos) 1261 if (pos < startpos)
1257 { 1262 {
1258 if (startpos < next) 1263 if (startpos < next)
1259 next = startpos; 1264 next = startpos;
1260 break; 1265 break;
1261 } 1266 }
1262 if (OVERLAY_POSITION (end) > pos) 1267 if (pos < OVERLAY_POSITION (end))
1263 { 1268 {
1264 if (idx == len) 1269 if (idx == len)
1265 { 1270 {
@@ -1299,6 +1304,9 @@ recenter_overlay_lists (buf, pos)
1299 1304
1300 /* If the overlay is not valid, get rid of it. */ 1305 /* If the overlay is not valid, get rid of it. */
1301 if (!OVERLAY_VALID (overlay)) 1306 if (!OVERLAY_VALID (overlay))
1307#if 1
1308 abort ();
1309#else
1302 { 1310 {
1303 /* Splice the cons cell TAIL out of overlays_before. */ 1311 /* Splice the cons cell TAIL out of overlays_before. */
1304 if (!NILP (prev)) 1312 if (!NILP (prev))
@@ -1308,6 +1316,7 @@ recenter_overlay_lists (buf, pos)
1308 tail = prev; 1316 tail = prev;
1309 continue; 1317 continue;
1310 } 1318 }
1319#endif
1311 1320
1312 beg = OVERLAY_START (overlay); 1321 beg = OVERLAY_START (overlay);
1313 end = OVERLAY_END (overlay); 1322 end = OVERLAY_END (overlay);
@@ -1335,7 +1344,7 @@ recenter_overlay_lists (buf, pos)
1335 1344
1336 otheroverlay = XCONS (other)->car; 1345 otheroverlay = XCONS (other)->car;
1337 if (! OVERLAY_VALID (otheroverlay)) 1346 if (! OVERLAY_VALID (otheroverlay))
1338 continue; 1347 abort ();
1339 1348
1340 otherbeg = OVERLAY_START (otheroverlay); 1349 otherbeg = OVERLAY_START (otheroverlay);
1341 if (OVERLAY_POSITION (otherbeg) >= where) 1350 if (OVERLAY_POSITION (otherbeg) >= where)
@@ -1368,6 +1377,9 @@ recenter_overlay_lists (buf, pos)
1368 1377
1369 /* If the overlay is not valid, get rid of it. */ 1378 /* If the overlay is not valid, get rid of it. */
1370 if (!OVERLAY_VALID (overlay)) 1379 if (!OVERLAY_VALID (overlay))
1380#if 1
1381 abort ();
1382#else
1371 { 1383 {
1372 /* Splice the cons cell TAIL out of overlays_after. */ 1384 /* Splice the cons cell TAIL out of overlays_after. */
1373 if (!NILP (prev)) 1385 if (!NILP (prev))
@@ -1377,6 +1389,7 @@ recenter_overlay_lists (buf, pos)
1377 tail = prev; 1389 tail = prev;
1378 continue; 1390 continue;
1379 } 1391 }
1392#endif
1380 1393
1381 beg = OVERLAY_START (overlay); 1394 beg = OVERLAY_START (overlay);
1382 end = OVERLAY_END (overlay); 1395 end = OVERLAY_END (overlay);
@@ -1409,7 +1422,7 @@ recenter_overlay_lists (buf, pos)
1409 1422
1410 otheroverlay = XCONS (other)->car; 1423 otheroverlay = XCONS (other)->car;
1411 if (! OVERLAY_VALID (otheroverlay)) 1424 if (! OVERLAY_VALID (otheroverlay))
1412 continue; 1425 abort ();
1413 1426
1414 otherend = OVERLAY_END (otheroverlay); 1427 otherend = OVERLAY_END (otheroverlay);
1415 if (OVERLAY_POSITION (otherend) <= where) 1428 if (OVERLAY_POSITION (otherend) <= where)
@@ -1429,6 +1442,14 @@ recenter_overlay_lists (buf, pos)
1429 XFASTINT (buf->overlay_center) = pos; 1442 XFASTINT (buf->overlay_center) = pos;
1430} 1443}
1431 1444
1445DEFUN ("overlayp", Foverlayp, Soverlayp, 1, 1, 0,
1446 "Return t if OBJECT is an overlay.")
1447 (object)
1448 Lisp_Object object;
1449{
1450 return (OVERLAYP (object) ? Qt : Qnil);
1451}
1452
1432DEFUN ("make-overlay", Fmake_overlay, Smake_overlay, 2, 3, 0, 1453DEFUN ("make-overlay", Fmake_overlay, Smake_overlay, 2, 3, 0,
1433 "Create a new overlay with range BEG to END in BUFFER.\n\ 1454 "Create a new overlay with range BEG to END in BUFFER.\n\
1434If omitted, BUFFER defaults to the current buffer.\n\ 1455If omitted, BUFFER defaults to the current buffer.\n\
@@ -1465,6 +1486,7 @@ BEG and END may be integers or markers.")
1465 end = Fset_marker (Fmake_marker (), end, buffer); 1486 end = Fset_marker (Fmake_marker (), end, buffer);
1466 1487
1467 overlay = Fcons (Fcons (beg, end), Qnil); 1488 overlay = Fcons (Fcons (beg, end), Qnil);
1489 XSETTYPE (overlay, Lisp_Overlay);
1468 1490
1469 /* Put the new overlay on the wrong list. */ 1491 /* Put the new overlay on the wrong list. */
1470 end = OVERLAY_END (overlay); 1492 end = OVERLAY_END (overlay);
@@ -1490,13 +1512,10 @@ If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now.")
1490{ 1512{
1491 struct buffer *b; 1513 struct buffer *b;
1492 1514
1493 if (!OVERLAY_VALID (overlay)) 1515 CHECK_OVERLAY (overlay, 0);
1494 error ("Invalid overlay object");
1495
1496 if (NILP (buffer)) 1516 if (NILP (buffer))
1497 buffer = Fmarker_buffer (OVERLAY_START (overlay)); 1517 buffer = Fmarker_buffer (OVERLAY_START (overlay));
1498 CHECK_BUFFER (buffer, 3); 1518 CHECK_BUFFER (buffer, 3);
1499
1500 CHECK_NUMBER_COERCE_MARKER (beg, 1); 1519 CHECK_NUMBER_COERCE_MARKER (beg, 1);
1501 CHECK_NUMBER_COERCE_MARKER (end, 1); 1520 CHECK_NUMBER_COERCE_MARKER (end, 1);
1502 1521
@@ -1555,15 +1574,16 @@ DEFUN ("delete-overlay", Fdelete_overlay, Sdelete_overlay, 1, 1, 0,
1555{ 1574{
1556 struct buffer *b; 1575 struct buffer *b;
1557 1576
1558 if (OVERLAY_VALID (overlay)) 1577 CHECK_OVERLAY (overlay, 0);
1559 b = XBUFFER (Fmarker_buffer (OVERLAY_START (overlay))); 1578
1560 else 1579 b = XBUFFER (Fmarker_buffer (OVERLAY_START (overlay)));
1561 /* Guess! */
1562 b = current_buffer;
1563 1580
1564 b->overlays_before = Fdelq (overlay, b->overlays_before); 1581 b->overlays_before = Fdelq (overlay, b->overlays_before);
1565 b->overlays_after = Fdelq (overlay, b->overlays_after); 1582 b->overlays_after = Fdelq (overlay, b->overlays_after);
1566 1583
1584 Fset_marker (OVERLAY_START (overlay), 1, Qnil);
1585 Fset_marker (OVERLAY_END (overlay), 1, Qnil);
1586
1567 redisplay_region (b, 1587 redisplay_region (b,
1568 OVERLAY_POSITION (OVERLAY_START (overlay)), 1588 OVERLAY_POSITION (OVERLAY_START (overlay)),
1569 OVERLAY_POSITION (OVERLAY_END (overlay))); 1589 OVERLAY_POSITION (OVERLAY_END (overlay)));
@@ -1677,13 +1697,18 @@ DEFUN ("overlay-get", Foverlay_get, Soverlay_get, 2, 2, 0,
1677 Lisp_Object overlay, prop; 1697 Lisp_Object overlay, prop;
1678{ 1698{
1679 Lisp_Object plist; 1699 Lisp_Object plist;
1680 for (plist = Fcdr_safe (Fcdr_safe (overlay)); 1700
1701 CHECK_OVERLAY (overlay, 0);
1702
1703 for (plist = Fcdr_safe (XCONS (overlay)->cdr);
1681 CONSP (plist) && CONSP (XCONS (plist)->cdr); 1704 CONSP (plist) && CONSP (XCONS (plist)->cdr);
1682 plist = XCONS (XCONS (plist)->cdr)->cdr) 1705 plist = XCONS (XCONS (plist)->cdr)->cdr)
1683 { 1706 {
1684 if (EQ (XCONS (plist)->car, prop)) 1707 if (EQ (XCONS (plist)->car, prop))
1685 return XCONS (XCONS (plist)->cdr)->car; 1708 return XCONS (XCONS (plist)->cdr)->car;
1686 } 1709 }
1710
1711 return Qnil;
1687} 1712}
1688 1713
1689DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0, 1714DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
@@ -1693,14 +1718,13 @@ DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
1693{ 1718{
1694 Lisp_Object plist, tail; 1719 Lisp_Object plist, tail;
1695 1720
1696 if (!OVERLAY_VALID (overlay)) 1721 CHECK_OVERLAY (overlay, 0);
1697 error ("Invalid overlay object");
1698 1722
1699 redisplay_region (XMARKER (OVERLAY_START (overlay))->buffer, 1723 redisplay_region (XMARKER (OVERLAY_START (overlay))->buffer,
1700 OVERLAY_POSITION (OVERLAY_START (overlay)), 1724 OVERLAY_POSITION (OVERLAY_START (overlay)),
1701 OVERLAY_POSITION (OVERLAY_END (overlay))); 1725 OVERLAY_POSITION (OVERLAY_END (overlay)));
1702 1726
1703 plist = Fcdr_safe (Fcdr_safe (overlay)); 1727 plist = Fcdr_safe (XCONS (overlay)->cdr);
1704 1728
1705 for (tail = plist; 1729 for (tail = plist;
1706 CONSP (tail) && CONSP (XCONS (tail)->cdr); 1730 CONSP (tail) && CONSP (XCONS (tail)->cdr);
@@ -1892,6 +1916,9 @@ syms_of_buffer ()
1892 staticpro (&Qprotected_field); 1916 staticpro (&Qprotected_field);
1893 staticpro (&Qpermanent_local); 1917 staticpro (&Qpermanent_local);
1894 staticpro (&Qkill_buffer_hook); 1918 staticpro (&Qkill_buffer_hook);
1919 staticpro (&Qoverlayp);
1920
1921 Qoverlayp = intern ("overlayp");
1895 1922
1896 Fput (Qprotected_field, Qerror_conditions, 1923 Fput (Qprotected_field, Qerror_conditions,
1897 Fcons (Qprotected_field, Fcons (Qerror, Qnil))); 1924 Fcons (Qprotected_field, Fcons (Qerror, Qnil)));
@@ -2215,6 +2242,7 @@ Automatically local in all buffers.");
2215 defsubr (&Slist_buffers); 2242 defsubr (&Slist_buffers);
2216 defsubr (&Skill_all_local_variables); 2243 defsubr (&Skill_all_local_variables);
2217 2244
2245 defsubr (&Soverlayp);
2218 defsubr (&Smake_overlay); 2246 defsubr (&Smake_overlay);
2219 defsubr (&Sdelete_overlay); 2247 defsubr (&Sdelete_overlay);
2220 defsubr (&Smove_overlay); 2248 defsubr (&Smove_overlay);