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.bugs Subject: bug#62333: 30.0.50; Issue with tree-sitter syntax tree during certain changes Date: Mon, 03 Apr 2023 15:31:20 +0300 Message-ID: <837cutw3jb.fsf@gnu.org> References: <87fs9yur7r.fsf@gmail.com> <83jzz5c8ml.fsf@gnu.org> <83edpdc6sn.fsf@gnu.org> <1ca302bf-99dc-7f9e-8544-063064a1cb21@yandex.ru> <831qlcdisi.fsf@gnu.org> <398721ad-79b0-3f6d-97b3-4902d9bfbe39@yandex.ru> <83wn34c2qa.fsf@gnu.org> <3b3d82d1-f0f6-a768-a5db-8dc9386a5a34@yandex.ru> <83r0tcbz8g.fsf@gnu.org> <1967361679760225@umbzx4hqxrw5qxo7.sas.yp-c.yandex.net> <83mt40bxzd.fsf@gnu.org> <83jzz4bugh.fsf@gnu.org> <3d64520c-54da-a04a-ed0d-a66b4e753f8a@yandex.ru> <831qlcaysh.fsf@gnu.org> <29679184-7366-0167-9e94-def97048f663@yandex.ru> <83v8inal29.fsf@gnu.org> <9886ffa5-ead2-50d5-a325-f6704b736ada@yandex.ru> <728618716b8c5349d27e@heytings.org> <83bkke9uue.fsf@gnu.org> <83ilel861g.fsf@gnu.org> <290987e0-821e-a231-c1c4-b40bb9542ffe@yandex.ru> <83lejf7r2o.fsf@gnu.org> <1c4c8b47-e4aa-242a-bb66-1d6b5c879de4@yandex.ru> <83wn2x30js.fsf@gnu.org> <7d4c5109-63ec-76a5-cab4-42f35dab9778@yandex.ru> <837cuw17cp.fsf@gnu.org> <6B99133E-F1DC-419B-B386-74CE7A4298E9@gmail.com> 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="21444"; mail-complaints-to="usenet@ciao.gmane.io" Cc: wkirschbaum@gmail.com, gregory@heytings.org, 62333@debbugs.gnu.org, dgutov@yandex.ru To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 03 14:32:52 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pjJMh-0005Qm-Kc for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Apr 2023 14:32:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pjJMI-00008r-A3; Mon, 03 Apr 2023 08:32:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjJLv-0008UL-J3 for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2023 08:32:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pjJLv-0004gF-4M for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2023 08:32:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pjJLu-0007RG-Gp for bug-gnu-emacs@gnu.org; Mon, 03 Apr 2023 08:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Apr 2023 12:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62333 X-GNU-PR-Package: emacs Original-Received: via spool by 62333-submit@debbugs.gnu.org id=B62333.168052506928527 (code B ref 62333); Mon, 03 Apr 2023 12:32:02 +0000 Original-Received: (at 62333) by debbugs.gnu.org; 3 Apr 2023 12:31:09 +0000 Original-Received: from localhost ([127.0.0.1]:43636 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjJL2-0007Q2-Ix for submit@debbugs.gnu.org; Mon, 03 Apr 2023 08:31:08 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46898) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pjJL1-0007Pd-GN for 62333@debbugs.gnu.org; Mon, 03 Apr 2023 08:31:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjJKv-0004U9-Ki; Mon, 03 Apr 2023 08:31:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=nECHwhsX8/0uccp/iPG3zuCcpTW0I+EY6bih+s/LS1A=; b=OlOnnHaIs5kT1FF9FUK4 +zQf4G3O5CNssyGiz5IyU+Lwy/P5Ie/LonRaSh2LUW9UODqcRg9hmz0hOQKpfFfKCw1NKtM2VE0hL Dr78sXfySpQV+msEoFhLlMSpf5640wyaWg5XhEMkcZ06C5NfOXjw4htVKIQoQRINUnSatAGvqapxv sAvlNo2qGwnrslaV3CHGPIL4gj9AE4BxGtP1PksxB2PSuWdBJMNcN6Yl/3nP/GHfyEof7IcGXma/3 FbBYswRuQsjPZaBnCKlWADjMxqqUMh8YRUZ/PKK8PX04bMXQCBFvA/NE5jjxAjfcgZcSucr6ab+bi RKh2zIkDrqy+Xw==; Original-Received: from [87.69.77.57] (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 1pjJKu-0006EJ-Ln; Mon, 03 Apr 2023 08:31:00 -0400 In-Reply-To: <6B99133E-F1DC-419B-B386-74CE7A4298E9@gmail.com> (message from Yuan Fu on Sun, 2 Apr 2023 15:08:01 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:259174 Archived-At: > From: Yuan Fu > Date: Sun, 2 Apr 2023 15:08:01 -0700 > Cc: Dmitry Gutov , > Wilhelm Kirschbaum , > Gregory Heytings , > 62333@debbugs.gnu.org > > >> I think the distinction lies between “I want to narrow to this defun and work on it without distraction” vs “treat this region as an isolated buffer”. The former used by users, the latter used by lisp programs like Info and mmm-mode. The former still considers the visible region part of the whole buffer, just temporarily narrowed for convenience, the latter wants to make everything thinks the visible region _is_ the whole buffer. > > > > Users can do both, for whatever reasons. > > Yeah, but it might be beneficial for lisp programs to be able to distinguish between the two types of narrowing, and act differently. I think we've found that to be impossible in practice. > >> It might be good for tree-sitter or other parsers to be exempt from (but still acknowledges) the first kind of narrowing. This way the parser can avoid unnecessary re-parse, and always provide the optimal information. We just need to modify tree-sitter functions to check for this narrowing and don’t return anything beyond the boundaries. It’s probably going to be a lot of hair, but should be doable, I think? > > > > I don't see why it would be a lot of hair. If a parser always has the > > regions on which it is supposed to work, then a Lisp program using a > > parser can simply widen the buffer when it needs to be sure a > > narrowing doesn't get in the way. > > Yes, the current situation is straightforward. I’m just saying that supporting what I described would require some work (let tree-sitter be able to peek outside the visible region but still pretend to respect narrowing). I don't understand where you see difficulties with that. We have already several features that widen the buffer momentarily, for whatever reasons. As long as the narrowing is restored after doing whatever it needed to widen for, there's no reason to "pretend" anything.