diff options
| author | Dmitry Antipov | 2012-12-03 18:13:06 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-12-03 18:13:06 +0400 |
| commit | 20edc1c9edbb8c896df0a54769a4da825017de22 (patch) | |
| tree | 5c431923887d8e48a1e932c4540f9aa48c611504 /src | |
| parent | 62c2e5ed3a9c991cef2594b44afc74893f6ce26b (diff) | |
| download | emacs-20edc1c9edbb8c896df0a54769a4da825017de22.tar.gz emacs-20edc1c9edbb8c896df0a54769a4da825017de22.zip | |
* lisp.h (modify_region): Rename to...
(modify_region_1): ...new prototype.
* textprop.c (modify_region): Now static. Adjust users.
* insdel.c (modify_region): Rename to...
(modify_region_1): ...new function to work with current buffer.
Adjust comment and users. Use true and false for boolean arg.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/casefiddle.c | 2 | ||||
| -rw-r--r-- | src/editfns.c | 14 | ||||
| -rw-r--r-- | src/insdel.c | 21 | ||||
| -rw-r--r-- | src/lisp.h | 2 | ||||
| -rw-r--r-- | src/textprop.c | 24 |
6 files changed, 42 insertions, 30 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 035ef88c485..5bcd89e4ca1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,14 @@ | |||
| 1 | 2012-12-03 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2012-12-03 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | * lisp.h (modify_region): Rename to... | ||
| 4 | (modify_region_1): ...new prototype. | ||
| 5 | * textprop.c (modify_region): Now static. Adjust users. | ||
| 6 | * insdel.c (modify_region): Rename to... | ||
| 7 | (modify_region_1): ...new function to work with current buffer. | ||
| 8 | Adjust comment and users. Use true and false for booleans. | ||
| 9 | |||
| 10 | 2012-12-03 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 11 | |||
| 3 | * alloc.c (free_save_value): New function. | 12 | * alloc.c (free_save_value): New function. |
| 4 | (safe_alloca_unwind): Use it. | 13 | (safe_alloca_unwind): Use it. |
| 5 | * lisp.h (free_save_value): New prototype. | 14 | * lisp.h (free_save_value): New prototype. |
diff --git a/src/casefiddle.c b/src/casefiddle.c index e3654627576..d9c6a078973 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c | |||
| @@ -213,7 +213,7 @@ casify_region (enum case_action flag, Lisp_Object b, Lisp_Object e) | |||
| 213 | validate_region (&b, &e); | 213 | validate_region (&b, &e); |
| 214 | start = XFASTINT (b); | 214 | start = XFASTINT (b); |
| 215 | end = XFASTINT (e); | 215 | end = XFASTINT (e); |
| 216 | modify_region (current_buffer, start, end, 0); | 216 | modify_region_1 (start, end, false); |
| 217 | record_change (start, end - start); | 217 | record_change (start, end - start); |
| 218 | start_byte = CHAR_TO_BYTE (start); | 218 | start_byte = CHAR_TO_BYTE (start); |
| 219 | 219 | ||
diff --git a/src/editfns.c b/src/editfns.c index 390ce21bbca..d60f417e561 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2922,7 +2922,7 @@ Both characters must have the same length of multi-byte form. */) | |||
| 2922 | else if (!changed) | 2922 | else if (!changed) |
| 2923 | { | 2923 | { |
| 2924 | changed = -1; | 2924 | changed = -1; |
| 2925 | modify_region (current_buffer, pos, XINT (end), 0); | 2925 | modify_region_1 (pos, XINT (end), false); |
| 2926 | 2926 | ||
| 2927 | if (! NILP (noundo)) | 2927 | if (! NILP (noundo)) |
| 2928 | { | 2928 | { |
| @@ -3098,7 +3098,7 @@ It returns the number of characters changed. */) | |||
| 3098 | pos = XINT (start); | 3098 | pos = XINT (start); |
| 3099 | pos_byte = CHAR_TO_BYTE (pos); | 3099 | pos_byte = CHAR_TO_BYTE (pos); |
| 3100 | end_pos = XINT (end); | 3100 | end_pos = XINT (end); |
| 3101 | modify_region (current_buffer, pos, end_pos, 0); | 3101 | modify_region_1 (pos, end_pos, false); |
| 3102 | 3102 | ||
| 3103 | cnt = 0; | 3103 | cnt = 0; |
| 3104 | for (; pos < end_pos; ) | 3104 | for (; pos < end_pos; ) |
| @@ -4622,7 +4622,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4622 | 4622 | ||
| 4623 | if (end1 == start2) /* adjacent regions */ | 4623 | if (end1 == start2) /* adjacent regions */ |
| 4624 | { | 4624 | { |
| 4625 | modify_region (current_buffer, start1, end2, 0); | 4625 | modify_region_1 (start1, end2, false); |
| 4626 | record_change (start1, len1 + len2); | 4626 | record_change (start1, len1 + len2); |
| 4627 | 4627 | ||
| 4628 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4628 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| @@ -4681,8 +4681,8 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4681 | { | 4681 | { |
| 4682 | USE_SAFE_ALLOCA; | 4682 | USE_SAFE_ALLOCA; |
| 4683 | 4683 | ||
| 4684 | modify_region (current_buffer, start1, end1, 0); | 4684 | modify_region_1 (start1, end1, false); |
| 4685 | modify_region (current_buffer, start2, end2, 0); | 4685 | modify_region_1 (start2, end2, false); |
| 4686 | record_change (start1, len1); | 4686 | record_change (start1, len1); |
| 4687 | record_change (start2, len2); | 4687 | record_change (start2, len2); |
| 4688 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4688 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| @@ -4715,7 +4715,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4715 | { | 4715 | { |
| 4716 | USE_SAFE_ALLOCA; | 4716 | USE_SAFE_ALLOCA; |
| 4717 | 4717 | ||
| 4718 | modify_region (current_buffer, start1, end2, 0); | 4718 | modify_region_1 (start1, end2, false); |
| 4719 | record_change (start1, (end2 - start1)); | 4719 | record_change (start1, (end2 - start1)); |
| 4720 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4720 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| 4721 | tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); | 4721 | tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); |
| @@ -4748,7 +4748,7 @@ Transposing beyond buffer boundaries is an error. */) | |||
| 4748 | USE_SAFE_ALLOCA; | 4748 | USE_SAFE_ALLOCA; |
| 4749 | 4749 | ||
| 4750 | record_change (start1, (end2 - start1)); | 4750 | record_change (start1, (end2 - start1)); |
| 4751 | modify_region (current_buffer, start1, end2, 0); | 4751 | modify_region_1 (start1, end2, false); |
| 4752 | 4752 | ||
| 4753 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); | 4753 | tmp_interval1 = copy_intervals (cur_intv, start1, len1); |
| 4754 | tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); | 4754 | tmp_interval_mid = copy_intervals (cur_intv, end1, len_mid); |
diff --git a/src/insdel.c b/src/insdel.c index 87010cd8251..892ca3d5216 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -1755,9 +1755,9 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte, | |||
| 1755 | 1755 | ||
| 1756 | return deletion; | 1756 | return deletion; |
| 1757 | } | 1757 | } |
| 1758 | 1758 | ||
| 1759 | /* Call this if you're about to change the region of BUFFER from | 1759 | /* Call this if you're about to change the region of current buffer |
| 1760 | character positions START to END. This checks the read-only | 1760 | from character positions START to END. This checks the read-only |
| 1761 | properties of the region, calls the necessary modification hooks, | 1761 | properties of the region, calls the necessary modification hooks, |
| 1762 | and warns the next redisplay that it should pay attention to that | 1762 | and warns the next redisplay that it should pay attention to that |
| 1763 | area. | 1763 | area. |
| @@ -1766,16 +1766,11 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte, | |||
| 1766 | Otherwise set CHARS_MODIFF to the new value of MODIFF. */ | 1766 | Otherwise set CHARS_MODIFF to the new value of MODIFF. */ |
| 1767 | 1767 | ||
| 1768 | void | 1768 | void |
| 1769 | modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end, | 1769 | modify_region_1 (ptrdiff_t start, ptrdiff_t end, bool preserve_chars_modiff) |
| 1770 | bool preserve_chars_modiff) | ||
| 1771 | { | 1770 | { |
| 1772 | struct buffer *old_buffer = current_buffer; | ||
| 1773 | |||
| 1774 | set_buffer_internal (buffer); | ||
| 1775 | |||
| 1776 | prepare_to_modify_buffer (start, end, NULL); | 1771 | prepare_to_modify_buffer (start, end, NULL); |
| 1777 | 1772 | ||
| 1778 | BUF_COMPUTE_UNCHANGED (buffer, start - 1, end); | 1773 | BUF_COMPUTE_UNCHANGED (current_buffer, start - 1, end); |
| 1779 | 1774 | ||
| 1780 | if (MODIFF <= SAVE_MODIFF) | 1775 | if (MODIFF <= SAVE_MODIFF) |
| 1781 | record_first_change (); | 1776 | record_first_change (); |
| @@ -1783,11 +1778,9 @@ modify_region (struct buffer *buffer, ptrdiff_t start, ptrdiff_t end, | |||
| 1783 | if (! preserve_chars_modiff) | 1778 | if (! preserve_chars_modiff) |
| 1784 | CHARS_MODIFF = MODIFF; | 1779 | CHARS_MODIFF = MODIFF; |
| 1785 | 1780 | ||
| 1786 | bset_point_before_scroll (buffer, Qnil); | 1781 | bset_point_before_scroll (current_buffer, Qnil); |
| 1787 | |||
| 1788 | set_buffer_internal (old_buffer); | ||
| 1789 | } | 1782 | } |
| 1790 | 1783 | ||
| 1791 | /* Check that it is okay to modify the buffer between START and END, | 1784 | /* Check that it is okay to modify the buffer between START and END, |
| 1792 | which are char positions. | 1785 | which are char positions. |
| 1793 | 1786 | ||
diff --git a/src/lisp.h b/src/lisp.h index 4dae66eec96..9ce90c8a3f7 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2796,7 +2796,7 @@ extern void del_range_byte (ptrdiff_t, ptrdiff_t, bool); | |||
| 2796 | extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, bool); | 2796 | extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, bool); |
| 2797 | extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t, | 2797 | extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t, |
| 2798 | ptrdiff_t, ptrdiff_t, bool); | 2798 | ptrdiff_t, ptrdiff_t, bool); |
| 2799 | extern void modify_region (struct buffer *, ptrdiff_t, ptrdiff_t, bool); | 2799 | extern void modify_region_1 (ptrdiff_t, ptrdiff_t, bool); |
| 2800 | extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); | 2800 | extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); |
| 2801 | extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); | 2801 | extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); |
| 2802 | extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, | 2802 | extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, |
diff --git a/src/textprop.c b/src/textprop.c index 379eafb73f7..1ce44ad60ac 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -85,8 +85,18 @@ text_read_only (Lisp_Object propval) | |||
| 85 | xsignal0 (Qtext_read_only); | 85 | xsignal0 (Qtext_read_only); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | /* Prepare to modify the region of BUFFER from START to END. */ | ||
| 89 | |||
| 90 | static void | ||
| 91 | modify_region (Lisp_Object buffer, Lisp_Object start, Lisp_Object end) | ||
| 92 | { | ||
| 93 | struct buffer *buf = XBUFFER (buffer), *old = current_buffer; | ||
| 94 | |||
| 95 | set_buffer_internal (buf); | ||
| 96 | modify_region_1 (XINT (start), XINT (end), true); | ||
| 97 | set_buffer_internal (old); | ||
| 98 | } | ||
| 88 | 99 | ||
| 89 | |||
| 90 | /* Extract the interval at the position pointed to by BEGIN from | 100 | /* Extract the interval at the position pointed to by BEGIN from |
| 91 | OBJECT, a string or buffer. Additionally, check that the positions | 101 | OBJECT, a string or buffer. Additionally, check that the positions |
| 92 | pointed to by BEGIN and END are within the bounds of OBJECT, and | 102 | pointed to by BEGIN and END are within the bounds of OBJECT, and |
| @@ -1164,7 +1174,7 @@ Return t if any property value actually changed, nil otherwise. */) | |||
| 1164 | } | 1174 | } |
| 1165 | 1175 | ||
| 1166 | if (BUFFERP (object)) | 1176 | if (BUFFERP (object)) |
| 1167 | modify_region (XBUFFER (object), XINT (start), XINT (end), 1); | 1177 | modify_region (object, start, end); |
| 1168 | 1178 | ||
| 1169 | /* We are at the beginning of interval I, with LEN chars to scan. */ | 1179 | /* We are at the beginning of interval I, with LEN chars to scan. */ |
| 1170 | for (;;) | 1180 | for (;;) |
| @@ -1302,7 +1312,7 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, | |||
| 1302 | } | 1312 | } |
| 1303 | 1313 | ||
| 1304 | if (BUFFERP (object) && !NILP (coherent_change_p)) | 1314 | if (BUFFERP (object) && !NILP (coherent_change_p)) |
| 1305 | modify_region (XBUFFER (object), XINT (start), XINT (end), 1); | 1315 | modify_region (object, start, end); |
| 1306 | 1316 | ||
| 1307 | set_text_properties_1 (start, end, properties, object, i); | 1317 | set_text_properties_1 (start, end, properties, object, i); |
| 1308 | 1318 | ||
| @@ -1451,7 +1461,7 @@ Use `set-text-properties' if you want to remove all text properties. */) | |||
| 1451 | } | 1461 | } |
| 1452 | 1462 | ||
| 1453 | if (BUFFERP (object)) | 1463 | if (BUFFERP (object)) |
| 1454 | modify_region (XBUFFER (object), XINT (start), XINT (end), 1); | 1464 | modify_region (object, start, end); |
| 1455 | 1465 | ||
| 1456 | /* We are at the beginning of an interval, with len to scan */ | 1466 | /* We are at the beginning of an interval, with len to scan */ |
| 1457 | for (;;) | 1467 | for (;;) |
| @@ -1565,7 +1575,7 @@ Return t if any property was actually removed, nil otherwise. */) | |||
| 1565 | else if (LENGTH (i) == len) | 1575 | else if (LENGTH (i) == len) |
| 1566 | { | 1576 | { |
| 1567 | if (!modified && BUFFERP (object)) | 1577 | if (!modified && BUFFERP (object)) |
| 1568 | modify_region (XBUFFER (object), XINT (start), XINT (end), 1); | 1578 | modify_region (object, start, end); |
| 1569 | remove_properties (Qnil, properties, i, object); | 1579 | remove_properties (Qnil, properties, i, object); |
| 1570 | if (BUFFERP (object)) | 1580 | if (BUFFERP (object)) |
| 1571 | signal_after_change (XINT (start), XINT (end) - XINT (start), | 1581 | signal_after_change (XINT (start), XINT (end) - XINT (start), |
| @@ -1578,7 +1588,7 @@ Return t if any property was actually removed, nil otherwise. */) | |||
| 1578 | i = split_interval_left (i, len); | 1588 | i = split_interval_left (i, len); |
| 1579 | copy_properties (unchanged, i); | 1589 | copy_properties (unchanged, i); |
| 1580 | if (!modified && BUFFERP (object)) | 1590 | if (!modified && BUFFERP (object)) |
| 1581 | modify_region (XBUFFER (object), XINT (start), XINT (end), 1); | 1591 | modify_region (object, start, end); |
| 1582 | remove_properties (Qnil, properties, i, object); | 1592 | remove_properties (Qnil, properties, i, object); |
| 1583 | if (BUFFERP (object)) | 1593 | if (BUFFERP (object)) |
| 1584 | signal_after_change (XINT (start), XINT (end) - XINT (start), | 1594 | signal_after_change (XINT (start), XINT (end) - XINT (start), |
| @@ -1589,7 +1599,7 @@ Return t if any property was actually removed, nil otherwise. */) | |||
| 1589 | if (interval_has_some_properties_list (properties, i)) | 1599 | if (interval_has_some_properties_list (properties, i)) |
| 1590 | { | 1600 | { |
| 1591 | if (!modified && BUFFERP (object)) | 1601 | if (!modified && BUFFERP (object)) |
| 1592 | modify_region (XBUFFER (object), XINT (start), XINT (end), 1); | 1602 | modify_region (object, start, end); |
| 1593 | remove_properties (Qnil, properties, i, object); | 1603 | remove_properties (Qnil, properties, i, object); |
| 1594 | modified = 1; | 1604 | modified = 1; |
| 1595 | } | 1605 | } |