aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPip Cet2019-07-06 15:21:04 +0000
committerEli Zaretskii2019-07-06 19:20:53 +0300
commitc16a8fc180ad766fe7dd97af0bab99e3e4552690 (patch)
tree34692c2b9abded04d811711e8bb8690aac496c11 /src
parent27e727fb6ceca83a79a37b76741179c1406cc768 (diff)
downloademacs-c16a8fc180ad766fe7dd97af0bab99e3e4552690.tar.gz
emacs-c16a8fc180ad766fe7dd97af0bab99e3e4552690.zip
Update current buffer when changing text properties
* src/textprop.c (add_text_properties_1, set_text_properties) (set_text_properties_1, Fremove_text_properties): Switch buffer if necessary. (Bug#36190) * doc/lispref/text.texi (Examining Properties): Document performance FIXME.
Diffstat (limited to 'src')
-rw-r--r--src/textprop.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/textprop.c b/src/textprop.c
index 9023f4efa06..44c333256a6 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1142,6 +1142,18 @@ static Lisp_Object
1142add_text_properties_1 (Lisp_Object start, Lisp_Object end, 1142add_text_properties_1 (Lisp_Object start, Lisp_Object end,
1143 Lisp_Object properties, Lisp_Object object, 1143 Lisp_Object properties, Lisp_Object object,
1144 enum property_set_type set_type) { 1144 enum property_set_type set_type) {
1145 /* Ensure we run the modification hooks for the right buffer,
1146 without switching buffers twice (bug 36190). FIXME: Switching
1147 buffers is slow and often unnecessary. */
1148 if (BUFFERP (object) && XBUFFER (object) != current_buffer)
1149 {
1150 ptrdiff_t count = SPECPDL_INDEX ();
1151 record_unwind_current_buffer ();
1152 set_buffer_internal (XBUFFER (object));
1153 return unbind_to (count, add_text_properties_1 (start, end, properties,
1154 object, set_type));
1155 }
1156
1145 INTERVAL i, unchanged; 1157 INTERVAL i, unchanged;
1146 ptrdiff_t s, len; 1158 ptrdiff_t s, len;
1147 bool modified = false; 1159 bool modified = false;
@@ -1343,6 +1355,19 @@ Lisp_Object
1343set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, 1355set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties,
1344 Lisp_Object object, Lisp_Object coherent_change_p) 1356 Lisp_Object object, Lisp_Object coherent_change_p)
1345{ 1357{
1358 /* Ensure we run the modification hooks for the right buffer,
1359 without switching buffers twice (bug 36190). FIXME: Switching
1360 buffers is slow and often unnecessary. */
1361 if (BUFFERP (object) && XBUFFER (object) != current_buffer)
1362 {
1363 ptrdiff_t count = SPECPDL_INDEX ();
1364 record_unwind_current_buffer ();
1365 set_buffer_internal (XBUFFER (object));
1366 return unbind_to (count,
1367 set_text_properties (start, end, properties,
1368 object, coherent_change_p));
1369 }
1370
1346 INTERVAL i; 1371 INTERVAL i;
1347 bool first_time = true; 1372 bool first_time = true;
1348 1373
@@ -1413,6 +1438,20 @@ void
1413set_text_properties_1 (Lisp_Object start, Lisp_Object end, 1438set_text_properties_1 (Lisp_Object start, Lisp_Object end,
1414 Lisp_Object properties, Lisp_Object object, INTERVAL i) 1439 Lisp_Object properties, Lisp_Object object, INTERVAL i)
1415{ 1440{
1441 /* Ensure we run the modification hooks for the right buffer,
1442 without switching buffers twice (bug 36190). FIXME: Switching
1443 buffers is slow and often unnecessary. */
1444 if (BUFFERP (object) && XBUFFER (object) != current_buffer)
1445 {
1446 ptrdiff_t count = SPECPDL_INDEX ();
1447 record_unwind_current_buffer ();
1448 set_buffer_internal (XBUFFER (object));
1449
1450 set_text_properties_1 (start, end, properties, object, i);
1451 unbind_to (count, Qnil);
1452 return;
1453 }
1454
1416 INTERVAL prev_changed = NULL; 1455 INTERVAL prev_changed = NULL;
1417 ptrdiff_t s = XFIXNUM (start); 1456 ptrdiff_t s = XFIXNUM (start);
1418 ptrdiff_t len = XFIXNUM (end) - s; 1457 ptrdiff_t len = XFIXNUM (end) - s;
@@ -1495,6 +1534,19 @@ Return t if any property was actually removed, nil otherwise.
1495Use `set-text-properties' if you want to remove all text properties. */) 1534Use `set-text-properties' if you want to remove all text properties. */)
1496 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object) 1535 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object)
1497{ 1536{
1537 /* Ensure we run the modification hooks for the right buffer,
1538 without switching buffers twice (bug 36190). FIXME: Switching
1539 buffers is slow and often unnecessary. */
1540 if (BUFFERP (object) && XBUFFER (object) != current_buffer)
1541 {
1542 ptrdiff_t count = SPECPDL_INDEX ();
1543 record_unwind_current_buffer ();
1544 set_buffer_internal (XBUFFER (object));
1545 return unbind_to (count,
1546 Fremove_text_properties (start, end, properties,
1547 object));
1548 }
1549
1498 INTERVAL i, unchanged; 1550 INTERVAL i, unchanged;
1499 ptrdiff_t s, len; 1551 ptrdiff_t s, len;
1500 bool modified = false; 1552 bool modified = false;
@@ -1607,6 +1659,20 @@ markers). If OBJECT is a string, START and END are 0-based indices into it.
1607Return t if any property was actually removed, nil otherwise. */) 1659Return t if any property was actually removed, nil otherwise. */)
1608 (Lisp_Object start, Lisp_Object end, Lisp_Object list_of_properties, Lisp_Object object) 1660 (Lisp_Object start, Lisp_Object end, Lisp_Object list_of_properties, Lisp_Object object)
1609{ 1661{
1662 /* Ensure we run the modification hooks for the right buffer,
1663 without switching buffers twice (bug 36190). FIXME: Switching
1664 buffers is slow and often unnecessary. */
1665 if (BUFFERP (object) && XBUFFER (object) != current_buffer)
1666 {
1667 ptrdiff_t count = SPECPDL_INDEX ();
1668 record_unwind_current_buffer ();
1669 set_buffer_internal (XBUFFER (object));
1670 return unbind_to (count,
1671 Fremove_list_of_text_properties (start, end,
1672 list_of_properties,
1673 object));
1674 }
1675
1610 INTERVAL i, unchanged; 1676 INTERVAL i, unchanged;
1611 ptrdiff_t s, len; 1677 ptrdiff_t s, len;
1612 bool modified = false; 1678 bool modified = false;