diff options
| author | Dmitry Antipov | 2013-08-06 09:30:18 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-08-06 09:30:18 +0400 |
| commit | 00012b86257f33dd4e08e79b814f4a7ad6010713 (patch) | |
| tree | 1f01b7ccab453278d5e697ae2bf3dd34cd119a48 /src/textprop.c | |
| parent | 307764cc3a2afd363cae0a36a6d18dfa68788cb4 (diff) | |
| download | emacs-00012b86257f33dd4e08e79b814f4a7ad6010713.tar.gz emacs-00012b86257f33dd4e08e79b814f4a7ad6010713.zip | |
Invalidate region caches only if buffer text is going to be changed.
* lisp.h (modify_region_1): Remove 3rd arg and rename to...
(modify_text): ...new prototype.
(prepare_to_modify_buffer_1): New prototype.
* textprop.c (modify_region): Rename to...
(modify_text_properties): ...new function.
(add_text_properties_1, set_text_properties, Fremove_text_properties)
(Fremove_list_of_text_properties): Adjust users.
* insdel.c (modify_region_1): Remove 3rd arg and reimplement as...
(modify_text): ...new function.
(prepare_to_modify_buffer): Reimplement mostly as a wrapper for...
(prepare_to_modify_buffer_1): ...new function.
* casefiddle.c (casify_region):
* editfns.c (Fsubst_char_in_region, Ftranslate_region_internal)
(Ftranspose_regions): Use modify_text.
Diffstat (limited to 'src/textprop.c')
| -rw-r--r-- | src/textprop.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/textprop.c b/src/textprop.c index 282ae11d4ac..b804f345047 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -93,15 +93,25 @@ text_read_only (Lisp_Object propval) | |||
| 93 | xsignal0 (Qtext_read_only); | 93 | xsignal0 (Qtext_read_only); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /* Prepare to modify the region of BUFFER from START to END. */ | 96 | /* Prepare to modify the text properties of BUFFER from START to END. */ |
| 97 | 97 | ||
| 98 | static void | 98 | static void |
| 99 | modify_region (Lisp_Object buffer, Lisp_Object start, Lisp_Object end) | 99 | modify_text_properties (Lisp_Object buffer, Lisp_Object start, Lisp_Object end) |
| 100 | { | 100 | { |
| 101 | ptrdiff_t b = XINT (start), e = XINT (end); | ||
| 101 | struct buffer *buf = XBUFFER (buffer), *old = current_buffer; | 102 | struct buffer *buf = XBUFFER (buffer), *old = current_buffer; |
| 102 | 103 | ||
| 103 | set_buffer_internal (buf); | 104 | set_buffer_internal (buf); |
| 104 | modify_region_1 (XINT (start), XINT (end), true); | 105 | |
| 106 | prepare_to_modify_buffer_1 (b, e, NULL); | ||
| 107 | |||
| 108 | BUF_COMPUTE_UNCHANGED (buf, b - 1, e); | ||
| 109 | if (MODIFF <= SAVE_MODIFF) | ||
| 110 | record_first_change (); | ||
| 111 | MODIFF++; | ||
| 112 | |||
| 113 | bset_point_before_scroll (current_buffer, Qnil); | ||
| 114 | |||
| 105 | set_buffer_internal (old); | 115 | set_buffer_internal (old); |
| 106 | } | 116 | } |
| 107 | 117 | ||
| @@ -1213,9 +1223,9 @@ add_text_properties_1 (Lisp_Object start, Lisp_Object end, | |||
| 1213 | ptrdiff_t prev_total_length = TOTAL_LENGTH (i); | 1223 | ptrdiff_t prev_total_length = TOTAL_LENGTH (i); |
| 1214 | ptrdiff_t prev_pos = i->position; | 1224 | ptrdiff_t prev_pos = i->position; |
| 1215 | 1225 | ||
| 1216 | modify_region (object, start, end); | 1226 | modify_text_properties (object, start, end); |
| 1217 | /* If someone called us recursively as a side effect of | 1227 | /* If someone called us recursively as a side effect of |
| 1218 | modify_region, and changed the intervals behind our back | 1228 | modify_text_properties, and changed the intervals behind our back |
| 1219 | (could happen if lock_file, called by prepare_to_modify_buffer, | 1229 | (could happen if lock_file, called by prepare_to_modify_buffer, |
| 1220 | triggers redisplay, and that calls add-text-properties again | 1230 | triggers redisplay, and that calls add-text-properties again |
| 1221 | in the same buffer), we cannot continue with I, because its | 1231 | in the same buffer), we cannot continue with I, because its |
| @@ -1357,7 +1367,8 @@ into it. */) | |||
| 1357 | otherwise. */ | 1367 | otherwise. */ |
| 1358 | 1368 | ||
| 1359 | Lisp_Object | 1369 | Lisp_Object |
| 1360 | set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, Lisp_Object coherent_change_p) | 1370 | set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, |
| 1371 | Lisp_Object object, Lisp_Object coherent_change_p) | ||
| 1361 | { | 1372 | { |
| 1362 | register INTERVAL i; | 1373 | register INTERVAL i; |
| 1363 | Lisp_Object ostart, oend; | 1374 | Lisp_Object ostart, oend; |
| @@ -1403,7 +1414,7 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, | |||
| 1403 | } | 1414 | } |
| 1404 | 1415 | ||
| 1405 | if (BUFFERP (object) && !NILP (coherent_change_p)) | 1416 | if (BUFFERP (object) && !NILP (coherent_change_p)) |
| 1406 | modify_region (object, start, end); | 1417 | modify_text_properties (object, start, end); |
| 1407 | 1418 | ||
| 1408 | set_text_properties_1 (start, end, properties, object, i); | 1419 | set_text_properties_1 (start, end, properties, object, i); |
| 1409 | 1420 | ||
| @@ -1558,9 +1569,9 @@ Use `set-text-properties' if you want to remove all text properties. */) | |||
| 1558 | ptrdiff_t prev_total_length = TOTAL_LENGTH (i); | 1569 | ptrdiff_t prev_total_length = TOTAL_LENGTH (i); |
| 1559 | ptrdiff_t prev_pos = i->position; | 1570 | ptrdiff_t prev_pos = i->position; |
| 1560 | 1571 | ||
| 1561 | modify_region (object, start, end); | 1572 | modify_text_properties (object, start, end); |
| 1562 | /* If someone called us recursively as a side effect of | 1573 | /* If someone called us recursively as a side effect of |
| 1563 | modify_region, and changed the intervals behind our back | 1574 | modify_text_properties, and changed the intervals behind our back |
| 1564 | (could happen if lock_file, called by prepare_to_modify_buffer, | 1575 | (could happen if lock_file, called by prepare_to_modify_buffer, |
| 1565 | triggers redisplay, and that calls add-text-properties again | 1576 | triggers redisplay, and that calls add-text-properties again |
| 1566 | in the same buffer), we cannot continue with I, because its | 1577 | in the same buffer), we cannot continue with I, because its |
| @@ -1667,9 +1678,9 @@ Return t if any property was actually removed, nil otherwise. */) | |||
| 1667 | 1678 | ||
| 1668 | /* We are at the beginning of an interval, with len to scan. | 1679 | /* We are at the beginning of an interval, with len to scan. |
| 1669 | The flag `modified' records if changes have been made. | 1680 | The flag `modified' records if changes have been made. |
| 1670 | When object is a buffer, we must call modify_region before changes are | 1681 | When object is a buffer, we must call modify_text_properties |
| 1671 | made and signal_after_change when we are done. | 1682 | before changes are made and signal_after_change when we are done. |
| 1672 | We call modify_region before calling remove_properties if modified == 0, | 1683 | We call modify_text_properties before calling remove_properties if modified == 0, |
| 1673 | and we call signal_after_change before returning if modified != 0. */ | 1684 | and we call signal_after_change before returning if modified != 0. */ |
| 1674 | for (;;) | 1685 | for (;;) |
| 1675 | { | 1686 | { |
| @@ -1693,7 +1704,7 @@ Return t if any property was actually removed, nil otherwise. */) | |||
| 1693 | else if (LENGTH (i) == len) | 1704 | else if (LENGTH (i) == len) |
| 1694 | { | 1705 | { |
| 1695 | if (!modified && BUFFERP (object)) | 1706 | if (!modified && BUFFERP (object)) |
| 1696 | modify_region (object, start, end); | 1707 | modify_text_properties (object, start, end); |
| 1697 | remove_properties (Qnil, properties, i, object); | 1708 | remove_properties (Qnil, properties, i, object); |
| 1698 | if (BUFFERP (object)) | 1709 | if (BUFFERP (object)) |
| 1699 | signal_after_change (XINT (start), XINT (end) - XINT (start), | 1710 | signal_after_change (XINT (start), XINT (end) - XINT (start), |
| @@ -1706,7 +1717,7 @@ Return t if any property was actually removed, nil otherwise. */) | |||
| 1706 | i = split_interval_left (i, len); | 1717 | i = split_interval_left (i, len); |
| 1707 | copy_properties (unchanged, i); | 1718 | copy_properties (unchanged, i); |
| 1708 | if (!modified && BUFFERP (object)) | 1719 | if (!modified && BUFFERP (object)) |
| 1709 | modify_region (object, start, end); | 1720 | modify_text_properties (object, start, end); |
| 1710 | remove_properties (Qnil, properties, i, object); | 1721 | remove_properties (Qnil, properties, i, object); |
| 1711 | if (BUFFERP (object)) | 1722 | if (BUFFERP (object)) |
| 1712 | signal_after_change (XINT (start), XINT (end) - XINT (start), | 1723 | signal_after_change (XINT (start), XINT (end) - XINT (start), |
| @@ -1717,7 +1728,7 @@ Return t if any property was actually removed, nil otherwise. */) | |||
| 1717 | if (interval_has_some_properties_list (properties, i)) | 1728 | if (interval_has_some_properties_list (properties, i)) |
| 1718 | { | 1729 | { |
| 1719 | if (!modified && BUFFERP (object)) | 1730 | if (!modified && BUFFERP (object)) |
| 1720 | modify_region (object, start, end); | 1731 | modify_text_properties (object, start, end); |
| 1721 | remove_properties (Qnil, properties, i, object); | 1732 | remove_properties (Qnil, properties, i, object); |
| 1722 | modified = 1; | 1733 | modified = 1; |
| 1723 | } | 1734 | } |