diff options
| author | Richard M. Stallman | 1995-01-02 21:38:22 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-01-02 21:38:22 +0000 |
| commit | e5d967c90e1f6c9349294faedcee9c40595b809b (patch) | |
| tree | baff277653a3212d5bdea83a04e1fda58639c1af /src | |
| parent | 866bf2467752ce6339a3a6dab62f92d778e26d54 (diff) | |
| download | emacs-e5d967c90e1f6c9349294faedcee9c40595b809b.tar.gz emacs-e5d967c90e1f6c9349294faedcee9c40595b809b.zip | |
Use BUF_INTERVALS throughout.
(temp_set_point, set_point): Use BUF_PT.
(get_local_map): Get keymap from specified buffer, not current one.
Diffstat (limited to 'src')
| -rw-r--r-- | src/intervals.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/src/intervals.c b/src/intervals.c index f7560fb6b7a..75b5d6b8207 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -76,7 +76,7 @@ create_root_interval (parent) | |||
| 76 | { | 76 | { |
| 77 | new->total_length = (BUF_Z (XBUFFER (parent)) | 77 | new->total_length = (BUF_Z (XBUFFER (parent)) |
| 78 | - BUF_BEG (XBUFFER (parent))); | 78 | - BUF_BEG (XBUFFER (parent))); |
| 79 | XBUFFER (parent)->intervals = new; | 79 | BUF_INTERVALS (XBUFFER (parent)) = new; |
| 80 | } | 80 | } |
| 81 | else if (STRINGP (parent)) | 81 | else if (STRINGP (parent)) |
| 82 | { | 82 | { |
| @@ -414,7 +414,7 @@ balance_possible_root_interval (interval) | |||
| 414 | interval = balance_an_interval (interval); | 414 | interval = balance_an_interval (interval); |
| 415 | 415 | ||
| 416 | if (BUFFERP (parent)) | 416 | if (BUFFERP (parent)) |
| 417 | XBUFFER (parent)->intervals = interval; | 417 | BUF_INTERVALS (XBUFFER (parent)) = interval; |
| 418 | else if (STRINGP (parent)) | 418 | else if (STRINGP (parent)) |
| 419 | XSTRING (parent)->intervals = interval; | 419 | XSTRING (parent)->intervals = interval; |
| 420 | 420 | ||
| @@ -1052,7 +1052,7 @@ delete_interval (i) | |||
| 1052 | parent->parent = (INTERVAL) owner; | 1052 | parent->parent = (INTERVAL) owner; |
| 1053 | 1053 | ||
| 1054 | if (BUFFERP (owner)) | 1054 | if (BUFFERP (owner)) |
| 1055 | XBUFFER (owner)->intervals = parent; | 1055 | BUF_INTERVALS (XBUFFER (owner)) = parent; |
| 1056 | else if (STRINGP (owner)) | 1056 | else if (STRINGP (owner)) |
| 1057 | XSTRING (owner)->intervals = parent; | 1057 | XSTRING (owner)->intervals = parent; |
| 1058 | else | 1058 | else |
| @@ -1153,7 +1153,7 @@ adjust_intervals_for_deletion (buffer, start, length) | |||
| 1153 | int start, length; | 1153 | int start, length; |
| 1154 | { | 1154 | { |
| 1155 | register int left_to_delete = length; | 1155 | register int left_to_delete = length; |
| 1156 | register INTERVAL tree = buffer->intervals; | 1156 | register INTERVAL tree = BUF_INTERVALS (buffer); |
| 1157 | register int deleted; | 1157 | register int deleted; |
| 1158 | 1158 | ||
| 1159 | if (NULL_INTERVAL_P (tree)) | 1159 | if (NULL_INTERVAL_P (tree)) |
| @@ -1165,7 +1165,7 @@ adjust_intervals_for_deletion (buffer, start, length) | |||
| 1165 | 1165 | ||
| 1166 | if (length == TOTAL_LENGTH (tree)) | 1166 | if (length == TOTAL_LENGTH (tree)) |
| 1167 | { | 1167 | { |
| 1168 | buffer->intervals = NULL_INTERVAL; | 1168 | BUF_INTERVALS (buffer) = NULL_INTERVAL; |
| 1169 | return; | 1169 | return; |
| 1170 | } | 1170 | } |
| 1171 | 1171 | ||
| @@ -1181,10 +1181,10 @@ adjust_intervals_for_deletion (buffer, start, length) | |||
| 1181 | { | 1181 | { |
| 1182 | left_to_delete -= interval_deletion_adjustment (tree, start - 1, | 1182 | left_to_delete -= interval_deletion_adjustment (tree, start - 1, |
| 1183 | left_to_delete); | 1183 | left_to_delete); |
| 1184 | tree = buffer->intervals; | 1184 | tree = BUF_INTERVALS (buffer); |
| 1185 | if (left_to_delete == tree->total_length) | 1185 | if (left_to_delete == tree->total_length) |
| 1186 | { | 1186 | { |
| 1187 | buffer->intervals = NULL_INTERVAL; | 1187 | BUF_INTERVALS (buffer) = NULL_INTERVAL; |
| 1188 | return; | 1188 | return; |
| 1189 | } | 1189 | } |
| 1190 | } | 1190 | } |
| @@ -1200,11 +1200,11 @@ offset_intervals (buffer, start, length) | |||
| 1200 | struct buffer *buffer; | 1200 | struct buffer *buffer; |
| 1201 | int start, length; | 1201 | int start, length; |
| 1202 | { | 1202 | { |
| 1203 | if (NULL_INTERVAL_P (buffer->intervals) || length == 0) | 1203 | if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0) |
| 1204 | return; | 1204 | return; |
| 1205 | 1205 | ||
| 1206 | if (length > 0) | 1206 | if (length > 0) |
| 1207 | adjust_intervals_for_insertion (buffer->intervals, start, length); | 1207 | adjust_intervals_for_insertion (BUF_INTERVALS (buffer), start, length); |
| 1208 | else | 1208 | else |
| 1209 | adjust_intervals_for_deletion (buffer, start, -length); | 1209 | adjust_intervals_for_deletion (buffer, start, -length); |
| 1210 | } | 1210 | } |
| @@ -1426,9 +1426,11 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1426 | int inherit; | 1426 | int inherit; |
| 1427 | { | 1427 | { |
| 1428 | register INTERVAL under, over, this, prev; | 1428 | register INTERVAL under, over, this, prev; |
| 1429 | register INTERVAL tree = buffer->intervals; | 1429 | register INTERVAL tree; |
| 1430 | int middle; | 1430 | int middle; |
| 1431 | 1431 | ||
| 1432 | tree = BUF_INTERVALS (buffer); | ||
| 1433 | |||
| 1432 | /* If the new text has no properties, it becomes part of whatever | 1434 | /* If the new text has no properties, it becomes part of whatever |
| 1433 | interval it was inserted into. */ | 1435 | interval it was inserted into. */ |
| 1434 | if (NULL_INTERVAL_P (source)) | 1436 | if (NULL_INTERVAL_P (source)) |
| @@ -1441,8 +1443,8 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1441 | make_number (position + length), | 1443 | make_number (position + length), |
| 1442 | Qnil, buf); | 1444 | Qnil, buf); |
| 1443 | } | 1445 | } |
| 1444 | if (! NULL_INTERVAL_P (buffer->intervals)) | 1446 | if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer))) |
| 1445 | buffer->intervals = balance_an_interval (buffer->intervals); | 1447 | BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer)); |
| 1446 | return; | 1448 | return; |
| 1447 | } | 1449 | } |
| 1448 | 1450 | ||
| @@ -1454,7 +1456,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1454 | { | 1456 | { |
| 1455 | Lisp_Object buf; | 1457 | Lisp_Object buf; |
| 1456 | XSETBUFFER (buf, buffer); | 1458 | XSETBUFFER (buf, buffer); |
| 1457 | buffer->intervals = reproduce_tree (source, buf); | 1459 | BUF_INTERVALS (buffer) = reproduce_tree (source, buf); |
| 1458 | /* Explicitly free the old tree here. */ | 1460 | /* Explicitly free the old tree here. */ |
| 1459 | 1461 | ||
| 1460 | return; | 1462 | return; |
| @@ -1474,7 +1476,7 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1474 | some zero length intervals. Eventually, do something clever | 1476 | some zero length intervals. Eventually, do something clever |
| 1475 | about inserting properly. For now, just waste the old intervals. */ | 1477 | about inserting properly. For now, just waste the old intervals. */ |
| 1476 | { | 1478 | { |
| 1477 | buffer->intervals = reproduce_tree (source, tree->parent); | 1479 | BUF_INTERVALS (buffer) = reproduce_tree (source, tree->parent); |
| 1478 | /* Explicitly free the old tree here. */ | 1480 | /* Explicitly free the old tree here. */ |
| 1479 | 1481 | ||
| 1480 | return; | 1482 | return; |
| @@ -1534,8 +1536,8 @@ graft_intervals_into_buffer (source, position, length, buffer, inherit) | |||
| 1534 | over = next_interval (over); | 1536 | over = next_interval (over); |
| 1535 | } | 1537 | } |
| 1536 | 1538 | ||
| 1537 | if (! NULL_INTERVAL_P (buffer->intervals)) | 1539 | if (! NULL_INTERVAL_P (BUF_INTERVALS (buffer))) |
| 1538 | buffer->intervals = balance_an_interval (buffer->intervals); | 1540 | BUF_INTERVALS (buffer) = balance_an_interval (BUF_INTERVALS (buffer)); |
| 1539 | return; | 1541 | return; |
| 1540 | } | 1542 | } |
| 1541 | 1543 | ||
| @@ -1600,9 +1602,9 @@ set_point (position, buffer) | |||
| 1600 | int buffer_point; | 1602 | int buffer_point; |
| 1601 | register Lisp_Object obj; | 1603 | register Lisp_Object obj; |
| 1602 | int backwards = (position < BUF_PT (buffer)) ? 1 : 0; | 1604 | int backwards = (position < BUF_PT (buffer)) ? 1 : 0; |
| 1603 | int old_position = buffer->text.pt; | 1605 | int old_position = BUF_PT (buffer); |
| 1604 | 1606 | ||
| 1605 | if (position == buffer->text.pt) | 1607 | if (position == BUF_PT (buffer)) |
| 1606 | return; | 1608 | return; |
| 1607 | 1609 | ||
| 1608 | /* Check this now, before checking if the buffer has any intervals. | 1610 | /* Check this now, before checking if the buffer has any intervals. |
| @@ -1611,16 +1613,17 @@ set_point (position, buffer) | |||
| 1611 | if (position > BUF_Z (buffer) || position < BUF_BEG (buffer)) | 1613 | if (position > BUF_Z (buffer) || position < BUF_BEG (buffer)) |
| 1612 | abort (); | 1614 | abort (); |
| 1613 | 1615 | ||
| 1614 | if (NULL_INTERVAL_P (buffer->intervals)) | 1616 | if (NULL_INTERVAL_P (BUF_INTERVALS (buffer))) |
| 1615 | { | 1617 | { |
| 1616 | buffer->text.pt = position; | 1618 | |
| 1619 | BUF_PT (buffer) = position; | ||
| 1617 | return; | 1620 | return; |
| 1618 | } | 1621 | } |
| 1619 | 1622 | ||
| 1620 | /* Set TO to the interval containing the char after POSITION, | 1623 | /* Set TO to the interval containing the char after POSITION, |
| 1621 | and TOPREV to the interval containing the char before POSITION. | 1624 | and TOPREV to the interval containing the char before POSITION. |
| 1622 | Either one may be null. They may be equal. */ | 1625 | Either one may be null. They may be equal. */ |
| 1623 | to = find_interval (buffer->intervals, position); | 1626 | to = find_interval (BUF_INTERVALS (buffer), position); |
| 1624 | if (position == BUF_BEGV (buffer)) | 1627 | if (position == BUF_BEGV (buffer)) |
| 1625 | toprev = 0; | 1628 | toprev = 0; |
| 1626 | else if (to->position == position) | 1629 | else if (to->position == position) |
| @@ -1636,7 +1639,7 @@ set_point (position, buffer) | |||
| 1636 | and FROMPREV to the interval containing the char before PT. | 1639 | and FROMPREV to the interval containing the char before PT. |
| 1637 | Either one may be null. They may be equal. */ | 1640 | Either one may be null. They may be equal. */ |
| 1638 | /* We could cache this and save time. */ | 1641 | /* We could cache this and save time. */ |
| 1639 | from = find_interval (buffer->intervals, buffer_point); | 1642 | from = find_interval (BUF_INTERVALS (buffer), buffer_point); |
| 1640 | if (buffer_point == BUF_BEGV (buffer)) | 1643 | if (buffer_point == BUF_BEGV (buffer)) |
| 1641 | fromprev = 0; | 1644 | fromprev = 0; |
| 1642 | else if (from->position == BUF_PT (buffer)) | 1645 | else if (from->position == BUF_PT (buffer)) |
| @@ -1649,7 +1652,7 @@ set_point (position, buffer) | |||
| 1649 | /* Moving within an interval. */ | 1652 | /* Moving within an interval. */ |
| 1650 | if (to == from && toprev == fromprev && INTERVAL_VISIBLE_P (to)) | 1653 | if (to == from && toprev == fromprev && INTERVAL_VISIBLE_P (to)) |
| 1651 | { | 1654 | { |
| 1652 | buffer->text.pt = position; | 1655 | BUF_PT (buffer) = position; |
| 1653 | return; | 1656 | return; |
| 1654 | } | 1657 | } |
| 1655 | 1658 | ||
| @@ -1703,7 +1706,7 @@ set_point (position, buffer) | |||
| 1703 | One or the other may be null. */ | 1706 | One or the other may be null. */ |
| 1704 | } | 1707 | } |
| 1705 | 1708 | ||
| 1706 | buffer->text.pt = position; | 1709 | BUF_PT (buffer) = position; |
| 1707 | 1710 | ||
| 1708 | /* We run point-left and point-entered hooks here, iff the | 1711 | /* We run point-left and point-entered hooks here, iff the |
| 1709 | two intervals are not equivalent. These hooks take | 1712 | two intervals are not equivalent. These hooks take |
| @@ -1751,7 +1754,7 @@ temp_set_point (position, buffer) | |||
| 1751 | int position; | 1754 | int position; |
| 1752 | struct buffer *buffer; | 1755 | struct buffer *buffer; |
| 1753 | { | 1756 | { |
| 1754 | buffer->text.pt = position; | 1757 | BUF_PT (buffer) = position; |
| 1755 | } | 1758 | } |
| 1756 | 1759 | ||
| 1757 | /* Return the proper local map for position POSITION in BUFFER. | 1760 | /* Return the proper local map for position POSITION in BUFFER. |
| @@ -1766,24 +1769,24 @@ get_local_map (position, buffer) | |||
| 1766 | register INTERVAL interval; | 1769 | register INTERVAL interval; |
| 1767 | Lisp_Object prop, tem; | 1770 | Lisp_Object prop, tem; |
| 1768 | 1771 | ||
| 1769 | if (NULL_INTERVAL_P (buffer->intervals)) | 1772 | if (NULL_INTERVAL_P (BUF_INTERVALS (buffer))) |
| 1770 | return current_buffer->keymap; | 1773 | return buffer->keymap; |
| 1771 | 1774 | ||
| 1772 | /* Perhaps we should just change `position' to the limit. */ | 1775 | /* Perhaps we should just change `position' to the limit. */ |
| 1773 | if (position > BUF_Z (buffer) || position < BUF_BEG (buffer)) | 1776 | if (position > BUF_Z (buffer) || position < BUF_BEG (buffer)) |
| 1774 | abort (); | 1777 | abort (); |
| 1775 | 1778 | ||
| 1776 | interval = find_interval (buffer->intervals, position); | 1779 | interval = find_interval (BUF_INTERVALS (buffer), position); |
| 1777 | prop = textget (interval->plist, Qlocal_map); | 1780 | prop = textget (interval->plist, Qlocal_map); |
| 1778 | if (NILP (prop)) | 1781 | if (NILP (prop)) |
| 1779 | return current_buffer->keymap; | 1782 | return buffer->keymap; |
| 1780 | 1783 | ||
| 1781 | /* Use the local map only if it is valid. */ | 1784 | /* Use the local map only if it is valid. */ |
| 1782 | tem = Fkeymapp (prop); | 1785 | tem = Fkeymapp (prop); |
| 1783 | if (!NILP (tem)) | 1786 | if (!NILP (tem)) |
| 1784 | return prop; | 1787 | return prop; |
| 1785 | 1788 | ||
| 1786 | return current_buffer->keymap; | 1789 | return buffer->keymap; |
| 1787 | } | 1790 | } |
| 1788 | 1791 | ||
| 1789 | /* Call the modification hook functions in LIST, each with START and END. */ | 1792 | /* Call the modification hook functions in LIST, each with START and END. */ |
| @@ -1814,7 +1817,7 @@ verify_interval_modification (buf, start, end) | |||
| 1814 | struct buffer *buf; | 1817 | struct buffer *buf; |
| 1815 | int start, end; | 1818 | int start, end; |
| 1816 | { | 1819 | { |
| 1817 | register INTERVAL intervals = buf->intervals; | 1820 | register INTERVAL intervals = BUF_INTERVALS (buf); |
| 1818 | register INTERVAL i, prev; | 1821 | register INTERVAL i, prev; |
| 1819 | Lisp_Object hooks; | 1822 | Lisp_Object hooks; |
| 1820 | register Lisp_Object prev_mod_hooks; | 1823 | register Lisp_Object prev_mod_hooks; |
| @@ -2030,7 +2033,7 @@ copy_intervals_to_string (string, buffer, position, length) | |||
| 2030 | Lisp_Object string, buffer; | 2033 | Lisp_Object string, buffer; |
| 2031 | int position, length; | 2034 | int position, length; |
| 2032 | { | 2035 | { |
| 2033 | INTERVAL interval_copy = copy_intervals (XBUFFER (buffer)->intervals, | 2036 | INTERVAL interval_copy = copy_intervals (BUF_INTERVALS (XBUFFER (buffer)), |
| 2034 | position, length); | 2037 | position, length); |
| 2035 | if (NULL_INTERVAL_P (interval_copy)) | 2038 | if (NULL_INTERVAL_P (interval_copy)) |
| 2036 | return; | 2039 | return; |