From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: save-excursion and multi-thread? Date: Wed, 29 Sep 2021 15:45:06 +0300 Message-ID: <83ilyjim99.fsf@gnu.org> References: <5713E898-28B8-456C-992C-F0332FACA9FF@mit.edu> <8335prnqtq.fsf@gnu.org> <57C38454-3A17-47CC-A820-C7E63D8C2BBB@mit.edu> <83y27jmam8.fsf@gnu.org> <8DD13632-54F3-4FC4-8789-C2275820FA94@mit.edu> <83r1dbm9kc.fsf@gnu.org> <6FB8B808-3423-48A1-8B0F-8E106DEB9C56@mit.edu> <83o88fm8zb.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38336"; mail-complaints-to="usenet@ciao.gmane.io" Cc: qhong@mit.edu, emacs-devel@gnu.org To: rms@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 29 14:46:40 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVYyu-0009fU-93 for ged-emacs-devel@m.gmane-mx.org; Wed, 29 Sep 2021 14:46:40 +0200 Original-Received: from localhost ([::1]:39646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVYyt-0007pr-4E for ged-emacs-devel@m.gmane-mx.org; Wed, 29 Sep 2021 08:46:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVYxw-00071c-Ol for emacs-devel@gnu.org; Wed, 29 Sep 2021 08:45:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:55040) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVYxu-00038L-Si; Wed, 29 Sep 2021 08:45:40 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3889 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVYxI-0000B5-5G; Wed, 29 Sep 2021 08:45:00 -0400 In-Reply-To: (message from Richard Stallman on Tue, 28 Sep 2021 19:33:37 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:275785 Archived-At: > From: Richard Stallman > Cc: eliz@gnu.org, emacs-devel@gnu.org > Date: Tue, 28 Sep 2021 19:33:37 -0400 > > I think save-excursion in one thread ought to keep its locally-bound > point and mark within that thread alone. IIUC what you mean by "keep ... point alone", this already happens. (But not for mark: for that, you need save-mark-and-excursion nowadays.) That is, when the save-excursion form is exited, point is guaranteed to be where it was when we entered save-excursion. So a thread that wants to be sure its buffer's point will not move due to preemption should call save-excursion around any code that could switch threads. > In other words, it should work like dynamic variable bindings. > > So if a thread does not do save-excursion, it should share the value > of point in each buffer with the other threads. However, doing > save-excursion in a buffer should "locally bind" point (and mark) in > that buffer in the current thread, and that "local binding" should not > affect other threads or be affected by them. > > This does not necessarily require changing the way point is > implemented at low level. Indeed, I would prefer to avoid such > far-reaching changes if I were implementing it. It's enough to > make it possible for thread-switching to understand save-excursion > and DTRT. Note that this might expose background point movements to the user, depending on which thread runs redisplay. But if someone wants to work on this, be my guest. Based on our experience with Lisp threads since their introduction, I don't recommend that. 'Nough said.