diff options
| author | Paul Eggert | 2018-03-30 14:23:55 -0700 |
|---|---|---|
| committer | Noam Postavsky | 2018-06-03 12:48:13 -0400 |
| commit | 51ee8bc4483d3608f4355777aeabbb31887326d9 (patch) | |
| tree | 6807eeeac57c265955b8064426e39d6f4e9bdac6 /src | |
| parent | daa602338fd91aced720b5555c8b6ed389383831 (diff) | |
| download | emacs-51ee8bc4483d3608f4355777aeabbb31887326d9.tar.gz emacs-51ee8bc4483d3608f4355777aeabbb31887326d9.zip | |
Centralize Bug#30931 fix
* src/marker.c (detach_marker): New function.
* src/editfns.c (save_restriction_restore):
* src/insdel.c (signal_before_change): Use it.
(cherry picked from commit 6f66a43d7ad6cada2b7dbb6d07efe36be1dc7ecb)
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 9 | ||||
| -rw-r--r-- | src/insdel.c | 7 | ||||
| -rw-r--r-- | src/lisp.h | 3 | ||||
| -rw-r--r-- | src/marker.c | 13 |
4 files changed, 18 insertions, 14 deletions
diff --git a/src/editfns.c b/src/editfns.c index 1fcfc7aef63..b553a213e6c 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3876,12 +3876,9 @@ save_restriction_restore (Lisp_Object data) | |||
| 3876 | 3876 | ||
| 3877 | buf->clip_changed = 1; /* Remember that the narrowing changed. */ | 3877 | buf->clip_changed = 1; /* Remember that the narrowing changed. */ |
| 3878 | } | 3878 | } |
| 3879 | /* This isn’t needed anymore, so don’t wait for GC. Do not call | 3879 | /* Detach the markers, and free the cons instead of waiting for GC. */ |
| 3880 | free_marker on XCAR (data) or XCDR (data), though, since | 3880 | detach_marker (XCAR (data)); |
| 3881 | record_marker_adjustments may have put them on the buffer’s | 3881 | detach_marker (XCDR (data)); |
| 3882 | undo list (Bug#30931). Just detach them instead. */ | ||
| 3883 | Fset_marker (XCAR (data), Qnil, Qnil); | ||
| 3884 | Fset_marker (XCDR (data), Qnil, Qnil); | ||
| 3885 | free_cons (XCONS (data)); | 3882 | free_cons (XCONS (data)); |
| 3886 | } | 3883 | } |
| 3887 | else | 3884 | else |
diff --git a/src/insdel.c b/src/insdel.c index 697395c507b..173c2438347 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -2148,13 +2148,10 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int, | |||
| 2148 | FETCH_START, FETCH_END, Qnil); | 2148 | FETCH_START, FETCH_END, Qnil); |
| 2149 | } | 2149 | } |
| 2150 | 2150 | ||
| 2151 | /* Detach the markers now that we're done with them. Don't directly | ||
| 2152 | free them, since the change functions could have caused them to | ||
| 2153 | be inserted into the undo list (Bug#30931). */ | ||
| 2154 | if (! NILP (start_marker)) | 2151 | if (! NILP (start_marker)) |
| 2155 | Fset_marker (start_marker, Qnil, Qnil); | 2152 | detach_marker (start_marker); |
| 2156 | if (! NILP (end_marker)) | 2153 | if (! NILP (end_marker)) |
| 2157 | Fset_marker (end_marker, Qnil, Qnil); | 2154 | detach_marker (end_marker); |
| 2158 | RESTORE_VALUE; | 2155 | RESTORE_VALUE; |
| 2159 | 2156 | ||
| 2160 | unbind_to (count, Qnil); | 2157 | unbind_to (count, Qnil); |
diff --git a/src/lisp.h b/src/lisp.h index 9320345bff0..cd6d07288e0 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4018,7 +4018,8 @@ extern ptrdiff_t marker_byte_position (Lisp_Object); | |||
| 4018 | extern void clear_charpos_cache (struct buffer *); | 4018 | extern void clear_charpos_cache (struct buffer *); |
| 4019 | extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t); | 4019 | extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t); |
| 4020 | extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t); | 4020 | extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t); |
| 4021 | extern void unchain_marker (struct Lisp_Marker *marker); | 4021 | extern void detach_marker (Lisp_Object); |
| 4022 | extern void unchain_marker (struct Lisp_Marker *); | ||
| 4022 | extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); | 4023 | extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); |
| 4023 | extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); | 4024 | extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); |
| 4024 | extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, | 4025 | extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, |
diff --git a/src/marker.c b/src/marker.c index 7773c4fce0f..432fdd4cbfa 100644 --- a/src/marker.c +++ b/src/marker.c | |||
| @@ -530,7 +530,7 @@ POSITION is nil, makes marker point nowhere so it no longer slows down | |||
| 530 | editing in any buffer. Returns MARKER. */) | 530 | editing in any buffer. Returns MARKER. */) |
| 531 | (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer) | 531 | (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer) |
| 532 | { | 532 | { |
| 533 | return set_marker_internal (marker, position, buffer, 0); | 533 | return set_marker_internal (marker, position, buffer, false); |
| 534 | } | 534 | } |
| 535 | 535 | ||
| 536 | /* Like the above, but won't let the position be outside the visible part. */ | 536 | /* Like the above, but won't let the position be outside the visible part. */ |
| @@ -539,7 +539,7 @@ Lisp_Object | |||
| 539 | set_marker_restricted (Lisp_Object marker, Lisp_Object position, | 539 | set_marker_restricted (Lisp_Object marker, Lisp_Object position, |
| 540 | Lisp_Object buffer) | 540 | Lisp_Object buffer) |
| 541 | { | 541 | { |
| 542 | return set_marker_internal (marker, position, buffer, 1); | 542 | return set_marker_internal (marker, position, buffer, true); |
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | /* Set the position of MARKER, specifying both the | 545 | /* Set the position of MARKER, specifying both the |
| @@ -586,6 +586,15 @@ set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, | |||
| 586 | return marker; | 586 | return marker; |
| 587 | } | 587 | } |
| 588 | 588 | ||
| 589 | /* Detach a marker so that it no longer points anywhere and no longer | ||
| 590 | slows down editing. Do not free the marker, though, as a change | ||
| 591 | function could have inserted it into an undo list (Bug#30931). */ | ||
| 592 | void | ||
| 593 | detach_marker (Lisp_Object marker) | ||
| 594 | { | ||
| 595 | Fset_marker (marker, Qnil, Qnil); | ||
| 596 | } | ||
| 597 | |||
| 589 | /* Remove MARKER from the chain of whatever buffer it is in, | 598 | /* Remove MARKER from the chain of whatever buffer it is in, |
| 590 | leaving it points to nowhere. This is called during garbage | 599 | leaving it points to nowhere. This is called during garbage |
| 591 | collection, so we must be careful to ignore and preserve | 600 | collection, so we must be careful to ignore and preserve |