From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Turing on tree-sitter Date: Mon, 10 Oct 2022 16:24:21 +0000 Message-ID: <875ygrabpm.fsf@posteo.net> References: <83czb1jrm3.fsf@gnu.org> <87v8ot2nfi.fsf@posteo.net> <837d19jfia.fsf@gnu.org> <83edvgi3mx.fsf@gnu.org> <87r0zg5g76.fsf@thornhill.no> <78205E8D-B2D4-4460-BE0A-9BF7C627A79B@gmail.com> <87zge4b0lc.fsf@posteo.net> <83zge4gk9z.fsf@gnu.org> <434B99AD-F307-492A-8E9A-27C84CC575B0@gmail.com> Mime-Version: 1.0 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="8313"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Eli Zaretskii , theo@thornhill.no, emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 10 18:30:00 2022 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 1ohvfD-00020J-Lt for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Oct 2022 18:29:59 +0200 Original-Received: from localhost ([::1]:57608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohvfC-0007vl-Gy for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Oct 2022 12:29:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohva4-0003Ry-Dv for emacs-devel@gnu.org; Mon, 10 Oct 2022 12:24:40 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:55949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohvZx-0000Hh-7e for emacs-devel@gnu.org; Mon, 10 Oct 2022 12:24:36 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 33813240103 for ; Mon, 10 Oct 2022 18:24:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1665419070; bh=4LAHxLBVBxLSwyLR0bxED+ihXY4e/pY7dsxj5eeTixw=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=g/y4oNfrbvjxuwVLINDekam/sz+1iyCT+gJY8FhogqBuiCGNdH6XNmL1/1uRoEj+g v1K7wvr2G2/60Pi3NlsHcqQ+nDxG9/jZr1AVS2kae8uTwpT3vEZEBsHkbf8lwoTIFB bt8YVHx0wslp4BPz08m6c5NFRh2MDuL5ZL1Ow15FSPFUF/8k7M0c612WTGqSxj0Ybo ai8spDLB0nS+pTga/IUWcl48F64ekoAkecJ6ukm4Fu0fveGUk9SllAloogCDKcNM+4 hSGUq5KiklrBxD2XRQ90DjSN2nzpU4Q5QvLmW/OWBk883cSY45i0JqTT8qFwBjvr+f 8RikBgwKQxkOg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MmPPm6bCWz9rxL; Mon, 10 Oct 2022 18:24:26 +0200 (CEST) In-Reply-To: <434B99AD-F307-492A-8E9A-27C84CC575B0@gmail.com> (Yuan Fu's message of "Mon, 10 Oct 2022 09:06:29 -0700") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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:297382 Archived-At: Yuan Fu writes: >> On Oct 10, 2022, at 7:52 AM, Stefan Monnier w= rote: >>=20 >>>> Is there a reason we can't use a minor mode? Something like >>>>=20 >>>> (add-hook 'python-mode-hook #'treesit-mode) >>>>=20 >>>> or a list >>>>=20 >>>> (add-to-list 'treesit-modes 'python-mode) >>>>=20 >>>> ? >>>=20 >>> We could, if a minor mode is justified. When this was previously >>> brought up, someone said the justification for a minor mode was too >>> weak in most cases. But maybe we should revisit that idea. >>=20 >> I think a buffer-local `treesit-mode` plus a `global-treesit-mode` would >> make a lot of sense, from a user's perspective. This way they don't >> have to hunt for the name of the boolean variable that their mode >> decided to use to control the use of treesitter: all modes use the same >> boolean variable called `treesit-mode`. > > Usually users set buffer-local variables in a major mode hook, which > runs after the major mode is loaded, no? But major modes need to know > whether to use tree-sitter up-front. What if the hook is a noop and the mode definition just checks if the function is a member? Or is there no way to re-fontify a buffer? > I don=E2=80=99t think xxx-mode-use-tree-sitter would be hard to find if e= very > mode uses this pattern. Though now we are discussing adding separate > major modes which wouldn=E2=80=99t use this variable. I think that indeed > could be confusing. (How do I know if xxx language uses > xxx-mode-use-tree-sitter or a separate major mode > xxx-tree-sitter-mode?) I think the issue here is not so much discoverability, but consistency. Having to a different option for every mode can get annoying and is difficult to automate. It is also unnecessarily decentralised. That is why I think that having a single list like `treesit-modes' (by whatever name) would be nice to have. Using the easy customisation interface you'd represent it as a set/radio menu where you get a list of supported languages you can tick. >> Then again, to me a minor mode is something so cheap that the idea that >> "justification for a minor mode was too weak" is rather hard to grasp. > > I don=E2=80=99t think there is too much problem using minor modes, but mi= nor > modes wouldn=E2=80=99t fit very well with separate major modes. IMO it wo= uld > be weird if turning on tree-sitter-mode changes the major mode. I don't get why a `tree-sitter-mode' should change the major mode? > Yuan