From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Reliable after-change-functions (via: Using incremental parsing in Emacs) Date: Fri, 03 Apr 2020 21:31:27 +0300 Message-ID: <83369kwhds.fsf@gnu.org> References: <83369o1khx.fsf@gnu.org> <83imijz68s.fsf@gnu.org> <831rp7ypam.fsf@gnu.org> <86wo6yhj4d.fsf@stephe-leake.org> <83r1x6x8df.fsf@gnu.org> <86tv21fgls.fsf@stephe-leake.org> <83zhbtvwsm.fsf@gnu.org> <868sjcfoon.fsf@stephe-leake.org> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="119861"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stephen Leake Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 03 20:32:36 2020 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 1jKR7L-000V29-JE for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Apr 2020 20:32:35 +0200 Original-Received: from localhost ([::1]:59602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jKR7K-00073O-Lc for ged-emacs-devel@m.gmane-mx.org; Fri, 03 Apr 2020 14:32:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37956) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jKR6T-00068j-UF for emacs-devel@gnu.org; Fri, 03 Apr 2020 14:31:43 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:55492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jKR6T-000425-OQ; Fri, 03 Apr 2020 14:31:41 -0400 Original-Received: from [176.228.60.248] (port=1687 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jKR6S-0002FF-QM; Fri, 03 Apr 2020 14:31:41 -0400 In-Reply-To: <868sjcfoon.fsf@stephe-leake.org> (message from Stephen Leake on Fri, 03 Apr 2020 09:45:44 -0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:246354 Archived-At: > From: Stephen Leake > Date: Fri, 03 Apr 2020 09:45:44 -0800 > > > Tree-sitter allows the application to define a "reader" function that > > it will then call to access buffer text. That function should cope > > with the gap. > > and also with the encoding, which you did not address. I mentioned that in another message: I don't think encoding is necessary in this case. > I don't see how that is different from the C level > buffer-substring. Certainly there should be a module function > buffer-substring that is as efficient as possible. If modules are allowed direct access to buffer text, then it's indeed not different. But the alternative that was discussed was different. May I suggest that you look at the code of the module which triggered this? > >> You mention "consing of Lisp objects" above, which says to me that the > >> text is stored in a more complex structure. > > > > I meant the consing that is necessary to make a buffer-substring that > > will be passed to the parser. > > Since are are calling the parser from C (if it is linked into Emacs, or > in a module), I still don't understand. Does C code have to cons to > create a string? If course. How else do you get a UTF-8 encoded string to pass to the parser as a copy of buffer text? > > I don't think tree-sitter does that, because the text it gets is > > ephemeral. If we pass it a buffer-substring, it's a temporary string > > which will be GCed after it's used; if we pass it pointers to buffer > > text, those pointers can be invalid after GC, because GC can relocate > > buffer text to a different memory region. > > Hmm. > https://tree-sitter.github.io/tree-sitter/using-parsers#providing-the-code > says: > > Syntax nodes store their position in the source code both in terms > of raw bytes and row/column coordinates Positions are okay; 'char *' pointers to buffer or string text are not.