diff options
| author | Eli Zaretskii | 2016-12-12 18:03:40 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-12-12 18:03:40 +0200 |
| commit | a416e1d6c111527205f3583c8d201bf95af6fa20 (patch) | |
| tree | 60e58859632f072952f84dee959eb0a88f3c097a /src/buffer.c | |
| parent | 00d4ba2794243763b818c013669e36c1d2c7de62 (diff) | |
| download | emacs-a416e1d6c111527205f3583c8d201bf95af6fa20.tar.gz emacs-a416e1d6c111527205f3583c8d201bf95af6fa20.zip | |
Fix point motion in cloned buffers
* src/thread.c (post_acquire_global_lock): Call
set_buffer_internal_2 instead of tricking set_buffer_internal_1
into resetting the current buffer even if it didn't change. This
avoids bug#25165, caused by failing to record the modified values
of point and mark, because current_buffer was set to NULL. Also,
don't bother re-setting the buffer if there was no thread switch,
as that just wastes cycles.
* src/buffer.c (set_buffer_internal_2): New function, with most of
the body of set_buffer_internal_1, but without the test for B
being identical to the current buffer.
(set_buffer_internal_1): Call set_buffer_internal_2 if B is not
identical to the current buffer.
* src/buffer.h (set_buffer_internal_2): Add prototype.
* test/src/thread-tests.el (thread-sticky-point): New test.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/buffer.c b/src/buffer.c index cea1ddb5ab3..babfba3e65f 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -2033,9 +2033,6 @@ DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0, | |||
| 2033 | void | 2033 | void |
| 2034 | set_buffer_internal_1 (register struct buffer *b) | 2034 | set_buffer_internal_1 (register struct buffer *b) |
| 2035 | { | 2035 | { |
| 2036 | register struct buffer *old_buf; | ||
| 2037 | register Lisp_Object tail; | ||
| 2038 | |||
| 2039 | #ifdef USE_MMAP_FOR_BUFFERS | 2036 | #ifdef USE_MMAP_FOR_BUFFERS |
| 2040 | if (b->text->beg == NULL) | 2037 | if (b->text->beg == NULL) |
| 2041 | enlarge_buffer_text (b, 0); | 2038 | enlarge_buffer_text (b, 0); |
| @@ -2044,6 +2041,17 @@ set_buffer_internal_1 (register struct buffer *b) | |||
| 2044 | if (current_buffer == b) | 2041 | if (current_buffer == b) |
| 2045 | return; | 2042 | return; |
| 2046 | 2043 | ||
| 2044 | set_buffer_internal_2 (b); | ||
| 2045 | } | ||
| 2046 | |||
| 2047 | /* Like set_buffer_internal_1, but doesn't check whether B is already | ||
| 2048 | the current buffer. Called upon switch of the current thread, see | ||
| 2049 | post_acquire_global_lock. */ | ||
| 2050 | void set_buffer_internal_2 (register struct buffer *b) | ||
| 2051 | { | ||
| 2052 | register struct buffer *old_buf; | ||
| 2053 | register Lisp_Object tail; | ||
| 2054 | |||
| 2047 | BUFFER_CHECK_INDIRECTION (b); | 2055 | BUFFER_CHECK_INDIRECTION (b); |
| 2048 | 2056 | ||
| 2049 | old_buf = current_buffer; | 2057 | old_buf = current_buffer; |