From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#62333: 30.0.50; Issue with tree-sitter syntax tree during certain changes Date: Sun, 2 Apr 2023 15:08:01 -0700 Message-ID: <6B99133E-F1DC-419B-B386-74CE7A4298E9@gmail.com> 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> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6865"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Wilhelm Kirschbaum , Gregory Heytings , 62333@debbugs.gnu.org, Dmitry Gutov To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 03 00:09:11 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 1pj5ss-0001e3-CU for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Apr 2023 00:09:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pj5sm-0001YC-JW; Sun, 02 Apr 2023 18:09:04 -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 1pj5sk-0001Y3-Sx for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 18:09:02 -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 1pj5sk-00062L-L8 for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 18:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pj5sk-0004YS-Gw for bug-gnu-emacs@gnu.org; Sun, 02 Apr 2023 18:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 02 Apr 2023 22:09: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.168047330317462 (code B ref 62333); Sun, 02 Apr 2023 22:09:02 +0000 Original-Received: (at 62333) by debbugs.gnu.org; 2 Apr 2023 22:08:23 +0000 Original-Received: from localhost ([127.0.0.1]:42902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pj5s7-0004Xa-2Y for submit@debbugs.gnu.org; Sun, 02 Apr 2023 18:08:23 -0400 Original-Received: from mail-pf1-f182.google.com ([209.85.210.182]:43996) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pj5s2-0004XK-Gq for 62333@debbugs.gnu.org; Sun, 02 Apr 2023 18:08:21 -0400 Original-Received: by mail-pf1-f182.google.com with SMTP id u38so17853789pfg.10 for <62333@debbugs.gnu.org>; Sun, 02 Apr 2023 15:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680473293; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=It6n/zqq+XTQ55Wqk5YyoxGGkDFJY8gwpB/h5Ghzj2A=; b=OLUId+fxU9DCTrBftttXAW56L4d3uf3oPcNPHYU0u6vVOOU0BLoZfEQZr9DI9FxzpX 1+18MzO+HpRELtpZbn6PqY7U7eHZV8j1n86uET1Jm6ERe49owI5qGEzJVxwdPB0ZWjSP Q08emzzuJWXAzKbGAaiSjaoZTJoOSvtgUQrnGSt+QJwkuZkS8aINQbWT/jOXPurP+53y 7tgAEv4U86swqG2v2tXcig9mDuZzOPaVop73KzpPmi7YFdAjLnNJpUPFDo61AoKc7gF1 nW8iLTf4VZrNxvwU9Fy250MZO2RRmQj7lGE4gMBc6oS6KEHbdjjIQko6a8QxslUh5vZ9 y4ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680473293; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=It6n/zqq+XTQ55Wqk5YyoxGGkDFJY8gwpB/h5Ghzj2A=; b=oZTG8M4omNXVhRkKrBIL5sVdMveM8rgxycfOOSLRu/P2a4omTvjCd8VOeUK5wZ/MSn 43CeN1YZNraHRRL9iw89PvPnFB5ra8CnHOwB53nBuzcix7qq95nLIJCCffF92Hr2Fdng 2Q4C3IJSPS55CnBTAwppI72QheDoJIBsGSsxFw2wh3WhmsPrS2Jto5K/l4mavZsY1uhT hquupi72hXqi4QicDrTnISnj/aYVns7RSOW1lWNGw3Cej0yevhCS3TGSfRszPO/D5enu R2NJvEMu5Ag0S5H4u3b0I9BEG51pupMeidg8Z5FZKvk75FpxZl9Kk+CAqNsLlZpB0dZ1 17og== X-Gm-Message-State: AAQBX9euhmouyQYFVrHmp6YipQyYlVqTTwt5yzF2AdSa5sXmMY7Gz6dg mgDUyHEbNOzXV6FFEqxtFZU= X-Google-Smtp-Source: AKy350ZX7QWjenijuZ3UFWoL7LEI8B81OTVoRKZlOSwRzQxP3g0xVSTfDdanAoWDDAQSAHMJU4PkwQ== X-Received: by 2002:aa7:95a9:0:b0:62d:af5a:27bf with SMTP id a9-20020aa795a9000000b0062daf5a27bfmr15582638pfk.6.1680473292741; Sun, 02 Apr 2023 15:08:12 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id p3-20020a634f43000000b0050f85ef50d1sm4778288pgl.26.2023.04.02.15.08.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Apr 2023 15:08:12 -0700 (PDT) In-Reply-To: <837cuw17cp.fsf@gnu.org> X-Mailer: Apple Mail (2.3731.400.51.1.1) 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:259138 Archived-At: > On Mar 31, 2023, at 10:47 PM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Fri, 31 Mar 2023 11:43:49 -0700 >> Cc: Eli Zaretskii , >> Wilhelm Kirschbaum , >> Gregory Heytings , >> 62333@debbugs.gnu.org >>=20 >> I think the distinction lies between =E2=80=9CI want to narrow to = this defun and work on it without distraction=E2=80=9D vs =E2=80=9Ctreat = this region as an isolated buffer=E2=80=9D. 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. >=20 > 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. >> 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=E2=80=99t return anything beyond the boundaries. = It=E2=80=99s probably going to be a lot of hair, but should be doable, I = think? >=20 > 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=E2=80=99m 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). Yuan=