diff options
| author | Paul Eggert | 2018-03-30 14:23:55 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-03-30 14:26:26 -0700 |
| commit | 6f66a43d7ad6cada2b7dbb6d07efe36be1dc7ecb (patch) | |
| tree | 1a4fe997bc0d2997c3f7df516bba4331c3dccbbd | |
| parent | 96b8747d5c5d747af13fd84d8fe0308ef2a0ea7a (diff) | |
| download | emacs-6f66a43d7ad6cada2b7dbb6d07efe36be1dc7ecb.tar.gz emacs-6f66a43d7ad6cada2b7dbb6d07efe36be1dc7ecb.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.
| -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 84de6792738..608304c09ad 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3899,12 +3899,9 @@ save_restriction_restore (Lisp_Object data) | |||
| 3899 | 3899 | ||
| 3900 | buf->clip_changed = 1; /* Remember that the narrowing changed. */ | 3900 | buf->clip_changed = 1; /* Remember that the narrowing changed. */ |
| 3901 | } | 3901 | } |
| 3902 | /* This isn’t needed anymore, so don’t wait for GC. Do not call | 3902 | /* Detach the markers, and free the cons instead of waiting for GC. */ |
| 3903 | free_marker on XCAR (data) or XCDR (data), though, since | 3903 | detach_marker (XCAR (data)); |
| 3904 | record_marker_adjustments may have put them on the buffer’s | 3904 | detach_marker (XCDR (data)); |
| 3905 | undo list (Bug#30931). Just detach them instead. */ | ||
| 3906 | Fset_marker (XCAR (data), Qnil, Qnil); | ||
| 3907 | Fset_marker (XCDR (data), Qnil, Qnil); | ||
| 3908 | free_cons (XCONS (data)); | 3905 | free_cons (XCONS (data)); |
| 3909 | } | 3906 | } |
| 3910 | else | 3907 | 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 f471b216587..c931d9c8f05 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -4104,7 +4104,8 @@ extern ptrdiff_t marker_byte_position (Lisp_Object); | |||
| 4104 | extern void clear_charpos_cache (struct buffer *); | 4104 | extern void clear_charpos_cache (struct buffer *); |
| 4105 | extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t); | 4105 | extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t); |
| 4106 | extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t); | 4106 | extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t); |
| 4107 | extern void unchain_marker (struct Lisp_Marker *marker); | 4107 | extern void detach_marker (Lisp_Object); |
| 4108 | extern void unchain_marker (struct Lisp_Marker *); | ||
| 4108 | extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); | 4109 | extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object); |
| 4109 | extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); | 4110 | extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t); |
| 4110 | extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, | 4111 | extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, |
diff --git a/src/marker.c b/src/marker.c index 2a45ae636ed..2d5b05cc2b8 100644 --- a/src/marker.c +++ b/src/marker.c | |||
| @@ -560,7 +560,7 @@ POSITION is nil, makes marker point nowhere so it no longer slows down | |||
| 560 | editing in any buffer. Returns MARKER. */) | 560 | editing in any buffer. Returns MARKER. */) |
| 561 | (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer) | 561 | (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer) |
| 562 | { | 562 | { |
| 563 | return set_marker_internal (marker, position, buffer, 0); | 563 | return set_marker_internal (marker, position, buffer, false); |
| 564 | } | 564 | } |
| 565 | 565 | ||
| 566 | /* Like the above, but won't let the position be outside the visible part. */ | 566 | /* Like the above, but won't let the position be outside the visible part. */ |
| @@ -569,7 +569,7 @@ Lisp_Object | |||
| 569 | set_marker_restricted (Lisp_Object marker, Lisp_Object position, | 569 | set_marker_restricted (Lisp_Object marker, Lisp_Object position, |
| 570 | Lisp_Object buffer) | 570 | Lisp_Object buffer) |
| 571 | { | 571 | { |
| 572 | return set_marker_internal (marker, position, buffer, 1); | 572 | return set_marker_internal (marker, position, buffer, true); |
| 573 | } | 573 | } |
| 574 | 574 | ||
| 575 | /* Set the position of MARKER, specifying both the | 575 | /* Set the position of MARKER, specifying both the |
| @@ -616,6 +616,15 @@ set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, | |||
| 616 | return marker; | 616 | return marker; |
| 617 | } | 617 | } |
| 618 | 618 | ||
| 619 | /* Detach a marker so that it no longer points anywhere and no longer | ||
| 620 | slows down editing. Do not free the marker, though, as a change | ||
| 621 | function could have inserted it into an undo list (Bug#30931). */ | ||
| 622 | void | ||
| 623 | detach_marker (Lisp_Object marker) | ||
| 624 | { | ||
| 625 | Fset_marker (marker, Qnil, Qnil); | ||
| 626 | } | ||
| 627 | |||
| 619 | /* Remove MARKER from the chain of whatever buffer it is in, | 628 | /* Remove MARKER from the chain of whatever buffer it is in, |
| 620 | leaving it points to nowhere. This is called during garbage | 629 | leaving it points to nowhere. This is called during garbage |
| 621 | collection, so we must be careful to ignore and preserve | 630 | collection, so we must be careful to ignore and preserve |