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: Qiantan Hong
Subject: Re: save-excursion and multi-thread?
Date: Sun, 26 Sep 2021 18:28:44 +0000

>> 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?
I mean I manually move (C-{fbnp}) in the *scratch* buffer.

>> 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.
Similar thing can be said with special variables — they’re global and has only 
one value.
But what “global” actually means is dynamic scope. 
The values of special variables are associated with each dynamic scope 
(while values of lexical variables are associated with lexical scope),
and each let binding attaches a value to the current dynamic scope.
(or really, the current continuation).

Under multithread settings, each thread can have their own active dynamic scope 
(continuation),
therefore values of special variable doesn’t interfere.
I expects save-excursion to do the same.

> by "thread-local" movements?
I mean some thread uses save-excursion around some operations involving 
navigating/editing
the buffer, and expecting to *not* affect buffer state outside the dynamic 
scope of such code block.
The current behavior makes practical sense under no circumstances,
because we don’t know what thread will be switched to and what it will be doing
after a thread yield.


reply via email to

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