aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann1999-07-21 21:43:52 +0000
committerGerd Moellmann1999-07-21 21:43:52 +0000
commit9dd7eec678ffac9edb405660252b158b4f1451f6 (patch)
treedd453279556169a3bae1c56f75ad72d88d4516f9 /src
parentf403d3c379daa17497f8fd6ec8fe9331d14a35f1 (diff)
downloademacs-9dd7eec678ffac9edb405660252b158b4f1451f6.tar.gz
emacs-9dd7eec678ffac9edb405660252b158b4f1451f6.zip
(text_property_list): New.
(add_text_properties_from_list): New. (extend_property_ranges): New. (validate_interval_range): Make it externally visible.
Diffstat (limited to 'src')
-rw-r--r--src/textprop.c120
1 files changed, 119 insertions, 1 deletions
diff --git a/src/textprop.c b/src/textprop.c
index c7c7af563d5..c938fb441b8 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -103,7 +103,7 @@ Lisp_Object interval_insert_in_front_hooks;
103#define soft 0 103#define soft 0
104#define hard 1 104#define hard 1
105 105
106static INTERVAL 106INTERVAL
107validate_interval_range (object, begin, end, force) 107validate_interval_range (object, begin, end, force)
108 Lisp_Object object, *begin, *end; 108 Lisp_Object object, *begin, *end;
109 int force; 109 int force;
@@ -1422,6 +1422,124 @@ copy_text_properties (start, end, src, pos, dest, prop)
1422 1422
1423 return modified ? Qt : Qnil; 1423 return modified ? Qt : Qnil;
1424} 1424}
1425
1426
1427/* Return a list representing the text properties of OBJECT between
1428 START and END. if PROP is non-nil, report only on that property.
1429 Each result list element has the form (S E PLIST), where S and E
1430 are positions in OBJECT and PLIST is a property list containing the
1431 text properties of OBJECT between S and E. Value is nil if OBJECT
1432 doesn't contain text properties between START and END. */
1433
1434Lisp_Object
1435text_property_list (object, start, end, prop)
1436 Lisp_Object object, start, end, prop;
1437{
1438 struct interval *i;
1439 Lisp_Object result;
1440 int s, e;
1441
1442 result = Qnil;
1443
1444 i = validate_interval_range (object, &start, &end, soft);
1445 if (!NULL_INTERVAL_P (i))
1446 {
1447 int s = XINT (start);
1448 int e = XINT (end);
1449
1450 while (s < e)
1451 {
1452 int interval_end, len;
1453 Lisp_Object plist;
1454
1455 interval_end = i->position + LENGTH (i);
1456 if (interval_end > e)
1457 interval_end = e;
1458 len = interval_end - s;
1459
1460 plist = i->plist;
1461
1462 if (!NILP (prop))
1463 for (; !NILP (plist); plist = Fcdr (Fcdr (plist)))
1464 if (EQ (Fcar (plist), prop))
1465 {
1466 plist = Fcons (prop, Fcons (Fcar (Fcdr (plist)), Qnil));
1467 break;
1468 }
1469
1470 if (!NILP (plist))
1471 result = Fcons (Fcons (make_number (s),
1472 Fcons (make_number (s + len),
1473 Fcons (plist, Qnil))),
1474 result);
1475
1476 i = next_interval (i);
1477 if (NULL_INTERVAL_P (i))
1478 break;
1479 s = i->position;
1480 }
1481 }
1482
1483 return result;
1484}
1485
1486
1487/* Add text properties to OBJECT from LIST. LIST is a list of triples
1488 (START END PLIST), where START and END are positions and PLIST is a
1489 property list containing the text properties to add. Adjust START
1490 and END positions by DELTA before adding properties. Value is
1491 non-zero if OBJECT was modified. */
1492
1493int
1494add_text_properties_from_list (object, list, delta)
1495 Lisp_Object object, list, delta;
1496{
1497 struct gcpro gcpro1, gcpro2;
1498 int modified_p = 0;
1499
1500 GCPRO2 (list, object);
1501
1502 for (; CONSP (list); list = XCDR (list))
1503 {
1504 Lisp_Object item, start, end, plist, tem;
1505
1506 item = XCAR (list);
1507 start = make_number (XINT (XCAR (item)) + XINT (delta));
1508 end = make_number (XINT (XCAR (XCDR (item))) + XINT (delta));
1509 plist = XCAR (XCDR (XCDR (item)));
1510
1511 tem = Fadd_text_properties (start, end, plist, object);
1512 if (!NILP (tem))
1513 modified_p = 1;
1514 }
1515
1516 UNGCPRO;
1517 return modified_p;
1518}
1519
1520
1521
1522/* Modify end-points of ranges in LIST destructively. LIST is a list
1523 as returned from text_property_list. Change end-points equal to
1524 OLD_END to NEW_END. */
1525
1526void
1527extend_property_ranges (list, old_end, new_end)
1528 Lisp_Object list, old_end, new_end;
1529{
1530 for (; CONSP (list); list = XCDR (list))
1531 {
1532 Lisp_Object item, end;
1533
1534 item = XCAR (list);
1535 end = XCAR (XCDR (item));
1536
1537 if (EQ (end, old_end))
1538 XCONS (XCDR (item))->car = new_end;
1539 }
1540}
1541
1542
1425 1543
1426/* Call the modification hook functions in LIST, each with START and END. */ 1544/* Call the modification hook functions in LIST, each with START and END. */
1427 1545