unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Qiantan Hong <qhong@mit.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: save-excursion and multi-thread?
Date: Sun, 26 Sep 2021 18:28:44 +0000	[thread overview]
Message-ID: <57C38454-3A17-47CC-A820-C7E63D8C2BBB@mit.edu> (raw)
In-Reply-To: <8335prnqtq.fsf@gnu.org>

>> 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	other threads:[~2021-09-26 18:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26 17:41 save-excursion and multi-thread? Qiantan Hong
2021-09-26 18:18 ` Eli Zaretskii
2021-09-26 18:28   ` Qiantan Hong [this message]
2021-09-26 18:53     ` Eli Zaretskii
2021-09-26 19:09       ` Qiantan Hong
2021-09-26 19:14         ` Eli Zaretskii
2021-09-26 19:13       ` Qiantan Hong
2021-09-26 19:16         ` Eli Zaretskii
2021-09-26 19:21           ` Qiantan Hong
2021-09-26 19:29             ` Eli Zaretskii
2021-09-26 19:42               ` Qiantan Hong
2021-09-26 19:45                 ` Qiantan Hong
2021-09-27  4:36                   ` Eli Zaretskii
2021-09-28 23:33                   ` Richard Stallman
2021-09-29  1:41                     ` dick
2021-09-29  2:59                       ` Qiantan Hong
2021-10-01 22:32                       ` Richard Stallman
2021-09-29 12:45                     ` Eli Zaretskii
2021-10-01 22:35                       ` Richard Stallman
2021-09-27  4:36                 ` Eli Zaretskii
2021-09-27  5:00                   ` Qiantan Hong
2021-09-27  5:54                     ` Eli Zaretskii
2021-09-27  6:14                       ` Qiantan Hong
2021-09-27 10:13                         ` Eli Zaretskii
2021-09-26 18:21 ` Tassilo Horn
2021-09-26 19:02   ` Eli Zaretskii
2021-09-27 19:35 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57C38454-3A17-47CC-A820-C7E63D8C2BBB@mit.edu \
    --to=qhong@mit.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).