From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: Re: Average-user-facing interface for tree-sitter Date: Mon, 24 Oct 2022 09:46:00 -0700 Message-ID: <86czahjhkn.fsf@stephe-leake.org> References: <8BAAB6CC-C8BA-4255-9E60-8963A828BE31@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="15638"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier , Theodor Thornhill , Lars Ingebrigtsen , emacs-devel To: Fu Yuan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 24 19:27:52 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 1on1Es-0003tk-SE for ged-emacs-devel@m.gmane-mx.org; Mon, 24 Oct 2022 19:27:51 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on0ar-0005k6-H9; Mon, 24 Oct 2022 12:46:29 -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 1on0ak-0005is-Bk for emacs-devel@gnu.org; Mon, 24 Oct 2022 12:46:22 -0400 Original-Received: from gproxy5-pub.mail.unifiedlayer.com ([67.222.38.55] helo=progateway7-pub.mail.pro1.eigbox.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on0af-0005ZQ-J2 for emacs-devel@gnu.org; Mon, 24 Oct 2022 12:46:22 -0400 Original-Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 9858C10043E67 for ; Mon, 24 Oct 2022 16:46:04 +0000 (UTC) Original-Received: from host2007.hostmonster.com ([67.20.76.71]) by cmsmtp with ESMTP id n0aRojPIGoMaxn0aRonWR9; Mon, 24 Oct 2022 16:46:04 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=X4CXlEfe c=1 sm=1 tr=0 ts=6356c14c a=dWLzHQi6WpdymmZIwiVdBw==:117 a=Fln8i1WyhtedwaIJAdHvmw==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=Qawa6l4ZSaYA:10:nop_rcvd_month_year a=vvvmwbhNdt4A:10:endurance_base64_authed_username_1 a=pGLkceISAAAA:8 a=_WanaVcz8X9kDhO1q3sA:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stephe-leake.org; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8PiQDSg8aGvql026PeKDjFqfTIEKIFf5M97KqlRf9wo=; b=OWuCfXIoGzRR3MPHMLtd2mcdfP /ka2dyvOlv7GG8oWaP2ffvQ/AlgEqwgk2FZnq0i7dNBicuFPF+xx+DgeDiHAr9stXOUE93S5LHEDg LqiojC634AcnDwkF7O3FGZn5tXbi4jB8OhImGa/JiTYJOCJaaeXM6fcFuIQ8Ax5wAq0piSVstf6Lv 2Hp4KmWt9z3T73jJ3DXoFp3QDKZJ5H8X7q7SEPD9715B1xbY5btJCujmNhWnkRDdrriG9Kf8+BymO GizMtwEWSVXvES4sJe9Q4pkIajvyaIR91Y5oKl0LcxC0PuadOhHvhY8PaR7q+j9Q6Jrb70wy9DaRA MEld+6WA==; Original-Received: from 135-180-197-170.fiber.dynamic.sonic.net ([135.180.197.170]:53215 helo=DESKTOP-G20DCG1) by host2007.hostmonster.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1on0aR-0023UJ-5x; Mon, 24 Oct 2022 10:46:03 -0600 In-Reply-To: <8BAAB6CC-C8BA-4255-9E60-8963A828BE31@gmail.com> (Fu Yuan's message of "Sat, 22 Oct 2022 18:59:35 -0700") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host2007.hostmonster.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stephe-leake.org X-BWhitelist: no X-Source-IP: 135.180.197.170 X-Source-L: No X-Exim-ID: 1on0aR-0023UJ-5x X-Source-Sender: 135-180-197-170.fiber.dynamic.sonic.net (DESKTOP-G20DCG1) [135.180.197.170]:53215 X-Source-Auth: stephen_leake@stephe-leake.org X-Email-Count: 5 X-Source-Cap: c3RlcGhlbGU7c3RlcGhlbGU7aG9zdDIwMDcuaG9zdG1vbnN0ZXIuY29t X-Local-Domain: yes Received-SPF: pass client-ip=67.222.38.55; envelope-from=stephen_leake@stephe-leake.org; helo=progateway7-pub.mail.pro1.eigbox.com X-Spam_score_int: 16 X-Spam_score: 1.6 X-Spam_bar: + X-Spam_report: (1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298396 Archived-At: Fu Yuan writes: >> =EF=BB=BF >>>=20 >>>>> Yeah. Shouldn't it be possible to just have a global var instead of a >>>>> mode? That way we can just look for that variable when enabling the >>>>> mode, and avoid calling anything other than what we want. At least f= or >>>>> the foreseeable future, enabling these per mode in the init file >>>>> shouldn't really be too much of a problem, IMO. When more users >>>>> actually get to try this we can get a feel for how the init should be= st >>>>> be handled. >>>>>=20 >>>>> To me the '*-use-tree-siter' defcustoms was beautiful :) >>>>=20 >>>> Back to centralized variable, perhaps? >>>=20 >>> I=E2=80=99ve thought really hard but didn=E2=80=99t come up with any br= illiant ideas, so I=E2=80=99m >>> going with centralized variable. Now, should I throw away recent commit= s and >>> create a new branch so we don=E2=80=99t have so many changes back and f= orth on js.el >>> and python.el? Plus feature/tree-sitter wouldn=E2=80=99t be used for lo= ng anyway >>> since it=E2=80=99s merging into master soon. >>=20 >> I'd wait a bit more to see if some other ideas come up first. > > Here=E2=80=99s my thought (that didn=E2=80=99t go anywhere): since major = modes sets a > plethora of local hooks and variables, only the major mode itself > knows how to reverse them. The cleanest way is probably to clear all > the local variables and hooks and re-run the major mode setup, which > suggests we should let major mode branch on whether to enable > tree-sitter during initialization.=20 That's what I ended up with in ada-mode; it decides on xref, indent, face backend in the major-mode function based on ada-*-backend variables. Actually, in a post-local-vars function; we need to allow dir-local and file-local hooks to set those vars. > I wonder if minor modes can somehow work with this model? It seems to me minor modes are only needed if you want to have different menus and keybindings for each minor mode. In ada-mode, I just enable menu entries based on the current backends; I left keybindings alone for now, which means many of them are undefined or non-functional. Not the ideal solution. Is there something written on why Emacs prefers minor-modes for choices like this? > It would be also nice to leave room for inclusion of other =E2=80=9Cbacke= nds=E2=80=9D > besides elisp and tree-sitter in the future. Right. wisi is one, available now. --=20 -- Stephe