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: Sun, 26 Sep 2021 21:18:25 +0300 Message-ID: <8335prnqtq.fsf@gnu.org> References: <5713E898-28B8-456C-992C-F0332FACA9FF@mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17820"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Qiantan Hong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 26 20:19:13 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 1mUYk5-0004Ta-Fe for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Sep 2021 20:19:13 +0200 Original-Received: from localhost ([::1]:46354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUYk4-0001Bu-H3 for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Sep 2021 14:19:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUYjK-0008Il-Px for emacs-devel@gnu.org; Sun, 26 Sep 2021 14:18:26 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:56428) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUYjK-0008O4-6U; Sun, 26 Sep 2021 14:18:26 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2106 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 1mUYjJ-0007uY-QX; Sun, 26 Sep 2021 14:18:26 -0400 In-Reply-To: <5713E898-28B8-456C-992C-F0332FACA9FF@mit.edu> (message from Qiantan Hong on Sun, 26 Sep 2021 17:41:17 +0000) 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:275524 Archived-At: > From: Qiantan Hong > Date: Sun, 26 Sep 2021 17:41:17 +0000 > Accept-Language: en-US > > I tried > (make-thread > (lambda () > (save-excursion (goto-char (point-min)) (sleep-for 1)))) > In *scratch*. > > It seems that after the thread yields (because of sleep-for) > it doesn’t restore point position It cannot, because the save-excursion form is still running. The call to sleep-for doesn't end the save-excursion form immediately, it ends it only after sleep-for returns > 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? > 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.