void
set_buffer_internal_1 (register struct buffer *b)
{
- register struct buffer *old_buf;
- register Lisp_Object tail;
-
#ifdef USE_MMAP_FOR_BUFFERS
if (b->text->beg == NULL)
enlarge_buffer_text (b, 0);
if (current_buffer == b)
return;
+ set_buffer_internal_2 (b);
+}
+
+/* Like set_buffer_internal_1, but doesn't check whether B is already
+ the current buffer. Called upon switch of the current thread, see
+ post_acquire_global_lock. */
+void set_buffer_internal_2 (register struct buffer *b)
+{
+ register struct buffer *old_buf;
+ register Lisp_Object tail;
+
BUFFER_CHECK_INDIRECTION (b);
old_buf = current_buffer;
extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **);
extern void validate_region (Lisp_Object *, Lisp_Object *);
extern void set_buffer_internal_1 (struct buffer *);
+extern void set_buffer_internal_2 (struct buffer *);
extern void set_buffer_temp (struct buffer *);
extern Lisp_Object buffer_local_value (Lisp_Object, Lisp_Object);
extern void record_buffer (Lisp_Object);
static void
post_acquire_global_lock (struct thread_state *self)
{
- Lisp_Object buffer;
struct thread_state *prev_thread = current_thread;
/* Do this early on, so that code below could signal errors (e.g.,
if (prev_thread != NULL)
unbind_for_thread_switch (prev_thread);
rebind_for_thread_switch ();
- }
- /* We need special handling to re-set the buffer. */
- XSETBUFFER (buffer, self->m_current_buffer);
- self->m_current_buffer = 0;
- set_buffer_internal (XBUFFER (buffer));
+ /* Set the new thread's current buffer. This needs to be done
+ even if it is the same buffer as that of the previous thread,
+ because of thread-local bindings. */
+ set_buffer_internal_2 (current_buffer);
+ }
if (!NILP (current_thread->error_symbol))
{
:group 'widget-faces))
(ert-deftest thread-errors ()
- "Test what happens when a thread signals an error."
+ "Test what happens when a thread signals an error."
(should (threadp (make-thread #'call-error "call-error")))
(should (threadp (make-thread #'thread-custom "thread-custom"))))
+(ert-deftest thread-sticky-point ()
+ "Test bug #25165 with point movement in cloned buffer."
+ (with-temp-buffer
+ (insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
+ (goto-char (point-min))
+ (clone-indirect-buffer nil nil)
+ (forward-char 20)
+ (sit-for 1)
+ (should (= (point) 21))))
+
;;; threads.el ends here