all messages for Emacs-related lists mirrored at yhetil.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 19:42:25 +0000	[thread overview]
Message-ID: <BB58CD04-B562-4E8B-997D-954007D00BE2@mit.edu> (raw)
In-Reply-To: <83o88fm8zb.fsf@gnu.org>



> On Sep 26, 2021, at 12:29 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Qiantan Hong <qhong@mit.edu>
>> CC: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
>> Date: Sun, 26 Sep 2021 19:21:38 +0000
>> 
>>>> I see. Can I fake that with indirect-buffer?
>>> 
>>> For moving point, I think you can.  But if you change the text, you
>>> will see the changes in the other threads as well.
>> That’s intended. 
>> I simply want point to behave like a proper global variable
> 
> But point is not a variable.  It's a property of a buffer, and all you
> have is a (read-only) accessor to that property.
> 
>> and save-excursion to behave like a proper let-binding.
> 
> You can always use save-excursion in the other thread, no?
Doesn’t looks like it’s protected
(progn
  (make-thread
   (lambda ()
     (save-excursion
       (sleep-for 5)
       (print (point)))))
  (make-thread
   (lambda ()
     (save-excursion
       (sleep-for 3)
       (goto-char (point-min))
       (sleep-for 3)))))
This prints 1 instead of the point before the first save-excursion enters.

Moreover, the other thread can be the main UI thread, 
I don’t know how I can protect it (assuming that save-excursion does protect,
although it actually doesn’t).

>> Does that convince you?
> 
> Convince me to do what? redesign and reimplement Lisp threads in
> Emacs with very different design goals?
Not doing anything, let’s figure out what’s correct first.
Whether to do the correct thing comes after that.
I also don’t think a redesign is necessary, we just need to
restore point state during thread switching, but I haven’t look at detail yet.

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

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

  git send-email \
    --in-reply-to=BB58CD04-B562-4E8B-997D-954007D00BE2@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.