unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Qiantan Hong <qhong@mit.edu>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: save-excursion and multi-thread?
Date: Mon, 27 Sep 2021 15:35:37 -0400	[thread overview]
Message-ID: <jwvtui5rf7p.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <5713E898-28B8-456C-992C-F0332FACA9FF@mit.edu> (Qiantan Hong's message of "Sun, 26 Sep 2021 17:41:17 +0000")

> Is this how save-excursion supposed to work?

Good question.

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

You might be right and maybe we should undo/redo such buffer movements when
context-switching, just like we do for the let bindings.

We already implement such undo/redo of this and similar forms in
a different yet related context: when we evaluate a user-specified
expression in a given stack frame (from the *Backtrace* debugger).
See `backtrace-eval`.

This said, your scenario smells like a race-condition to me, so maybe we
should instead "lock" the buffer's point while we're inside the
`save-excursion`.


        Stefan




      parent reply	other threads:[~2021-09-27 19:35 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
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 [this message]

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=jwvtui5rf7p.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=qhong@mit.edu \
    /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).