emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: save-excursion and multi-thread?


From: Eli Zaretskii
Subject: Re: save-excursion and multi-thread?
Date: Wed, 29 Sep 2021 15:45:06 +0300

> From: Richard Stallman <rms@gnu.org>
> Cc: eliz@gnu.org, emacs-devel@gnu.org
> Date: Tue, 28 Sep 2021 19:33:37 -0400
> 
> I think save-excursion in one thread ought to keep its locally-bound
> point and mark within that thread alone.

IIUC what you mean by "keep ... point alone", this already happens.
(But not for mark: for that, you need save-mark-and-excursion
nowadays.)  That is, when the save-excursion form is exited, point is
guaranteed to be where it was when we entered save-excursion.  So a
thread that wants to be sure its buffer's point will not move due to
preemption should call save-excursion around any code that could
switch threads.

> In other words, it should work like dynamic variable bindings.
> 
> So if a thread does not do save-excursion, it should share the value
> of point in each buffer with the other threads.  However, doing
> save-excursion in a buffer should "locally bind" point (and mark) in
> that buffer in the current thread, and that "local binding" should not
> affect other threads or be affected by them.
> 
> This does not necessarily require changing the way point is
> implemented at low level.  Indeed, I would prefer to avoid such
> far-reaching changes if I were implementing it.  It's enough to
> make it possible for thread-switching to understand save-excursion
> and DTRT.

Note that this might expose background point movements to the user,
depending on which thread runs redisplay.

But if someone wants to work on this, be my guest.  Based on our
experience with Lisp threads since their introduction, I don't
recommend that.  'Nough said.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]