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: Fri, 31 Mar 2023 11:43:49 -0700 Message-ID: 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> 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="24853"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Wilhelm Kirschbaum , Eli Zaretskii , Gregory Heytings , 62333@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 31 20:45:19 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 1piJkU-0006JL-S6 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 31 Mar 2023 20:45:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1piJkH-0004V8-Ug; Fri, 31 Mar 2023 14:45:05 -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 1piJkG-0004Uk-4U for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2023 14:45:04 -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 1piJkF-0001pc-6G for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2023 14:45:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1piJkE-0004Wk-4Z for bug-gnu-emacs@gnu.org; Fri, 31 Mar 2023 14:45: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: Fri, 31 Mar 2023 18:45: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.168028825017325 (code B ref 62333); Fri, 31 Mar 2023 18:45:02 +0000 Original-Received: (at 62333) by debbugs.gnu.org; 31 Mar 2023 18:44:10 +0000 Original-Received: from localhost ([127.0.0.1]:34510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1piJjN-0004VN-NS for submit@debbugs.gnu.org; Fri, 31 Mar 2023 14:44:10 -0400 Original-Received: from mail-pj1-f46.google.com ([209.85.216.46]:38695) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1piJjM-0004VA-0Z for 62333@debbugs.gnu.org; Fri, 31 Mar 2023 14:44:08 -0400 Original-Received: by mail-pj1-f46.google.com with SMTP id om3-20020a17090b3a8300b0023efab0e3bfso26354460pjb.3 for <62333@debbugs.gnu.org>; Fri, 31 Mar 2023 11:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680288242; 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=4g/gpaXRT8WMR7pwNs2V46B96H2voa3E3ylWVEmZQ4E=; b=S3/s4LfXCo6kB6UtQ1JgzcjkytjUOkAFqwwDaJorlzeaY34aHlE94Se2p1rG+I0IMF sgfYTo8puAmyr4gCO189kljv1xjzxamCLgLUlbzthNaRBeltDRA8BoVq/tHvKHpXWxox dfwKpNYSamtD9Mv1NoHWBsCjVxc5XfCtM4jc9vbVQ+DarANfwUCiRgkT9M1p+SBS7Frw aQaQK0jsgFVGExPE20Uf8Bf35JZxt4hsvKlJaSynagRP6WCIGeYepgH++EQRAGe8J0Qe JzoG4F1bBItyMzegVzPWwUW7hCcfT0ffIaBBYaJwF/RrbZ41HFuZjhiyy0KNwD40cNPO Le3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680288242; 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=4g/gpaXRT8WMR7pwNs2V46B96H2voa3E3ylWVEmZQ4E=; b=uN7P2AgtJoJn4OnnZiH7in+zsqkMl+ezffTsPfwqj4L3DIAAfanAgAtjCHPf5kAmjI SP/SpO40TuGhoDfbkWH7Kw8Yj4WWnJ5RCZxSn5cpbJoL/lnmeW4ftTRvDybLBL2bxKJX muiPsro79DnZ2a3nlYh7Lkkvch6cVp1D1iRdrlbxQE5ACBGBDIx13xM96b94XtFOuZHQ F0x8VGtUPNMCtxj8x0greS901+fDoBK4tSx9/luug1XPbc50XcWhgMCw/Zb9b87TJAUM rSAn3Fh00rOFok9qjOZNRTSGlMSYtseFZRnRZZx2SzsMnBAkdTSYAcZrnJAJkIFFiez5 Bx4w== X-Gm-Message-State: AO0yUKUI5gd4u3fC8ngHCmm/2VwMzD83FzKos2J9aX3yaTfpSySZBWLF Ao78gJUxVCVWCm+ll8dlmIg= X-Google-Smtp-Source: AK7set9wE0kKb/3IHvVfIMXMF5tDUJ8AaMwBt+q7t5ls7HQsnxugyD6+W38QRxh3pgDcs8FeOU+pOw== X-Received: by 2002:a05:6a20:8c14:b0:db:da69:3deb with SMTP id j20-20020a056a208c1400b000dbda693debmr22797140pzh.21.1680288241668; Fri, 31 Mar 2023 11:44:01 -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 s7-20020a62e707000000b0062dad805b76sm2194998pfh.143.2023.03.31.11.44.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2023 11:44:01 -0700 (PDT) In-Reply-To: <7d4c5109-63ec-76a5-cab4-42f35dab9778@yandex.ru> 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:259011 Archived-At: > On Mar 31, 2023, at 5:46 AM, Dmitry Gutov wrote: >=20 > On 31/03/2023 09:19, Eli Zaretskii wrote: >>> If we're talking about isearch, then that seems like a natural >>> consequence of visual effect (hiding the remainder of the buffer): = even >>> if isearch highlighted those other hits, they would not be visible. >> If you consider narrowing in this example to be "for visual effect", >> then everything in Emacs is "for visual effect". After all, Emacs is >> a visual editor, showing the results of editing to the user at all >> times. But this POV makes this part of the discussion useless. >=20 > Okay, let's rephrase that: instead of "visual effect", we can say it's = for "visually hiding" parts of buffers. But not for changing their = behaviors otherwise (e.g. changing syntax highlighting, etc). >=20 > In your other answer regarding the inside of a string, you seemed to = have a different idea, though. Like, user narrowing would be able to = affect all that stuff too. >=20 >>>> I was talking about user commands that narrow, so I'm not sure I >>>> understand how documentation could help. When the user types "C-x = n n", >>>> there's nothing Emacs can do except obey. >>> There is really only one main user command that narrows, and that's >>> narrow-to-region, bound to 'C-x n n'. >> Any user command can narrow as part of its job. >=20 > This subthread goes back to my complaint that commands don't know how = to *interpret* the current narrowing, thus which effects it should have. >=20 > To repeat: >=20 > Either narrowing should be used to change lexical/grammatical/etc > context, or it should not. Do we have any documentation that says one > or the other way? That should affect how Lisp code deals with > narrowing -- which interactive functions should widen, and so on. To maybe rephrase this in another way: 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. 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? This way, most lisp programs still obeys the narrowing, but specific = things like tree-sitter can choose to secretly look around while still = appear to obey the narrowing, when peeking around wouldn=E2=80=99t hurt. = And when the narrowing is really indented, tree-sitter (or other parser) = knows not to look around. Yuan=