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: Sun, 26 Sep 2021 21:18:25 +0300

> From: Qiantan Hong <qhong@mit.edu>
> Date: Sun, 26 Sep 2021 17:41:17 +0000
> Accept-Language: en-US
> 
> I tried
> (make-thread
>  (lambda ()
>    (save-excursion (goto-char (point-min)) (sleep-for 1))))
> In *scratch*.
> 
> It seems that after the thread yields (because of sleep-for)
> it doesn’t restore point position

It cannot, because the save-excursion form is still running.  The call
to sleep-for doesn't end the save-excursion form immediately, it ends
it only after sleep-for returns

> and after 1 second cursor is reseted to the original position,
> discarding any of my movements during this 1 second.

By "my movements" you mean what you did in another thread?

> Is this how save-excursion supposed to work?

Yes.

> It’s inconsistent with the behavior of special variable + dynamic bindings,
> which works currently under multi-thread.

Inconsistent in what way?

> What’s the supposed way to have “thread-local” movements?

What do you mean by "thread-local" movements?  Buffers are global, and
each buffer has only one point.




reply via email to

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