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.devel Subject: Re: Average-user-facing interface for tree-sitter Date: Fri, 14 Oct 2022 13:19:45 -0700 Message-ID: <89F05780-C9F9-4E6F-969F-57BCD36EEA45@gmail.com> References: <3A7E7CD1-74A7-4352-9DFE-FC982EAA398E@gmail.com> <87ilko9r9e.fsf@gnus.org> <9794E2EF-4DB5-4A04-90F0-3EB51E6BE008@gmail.com> <87v8ombrd2.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.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="15635"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 14 22:21:25 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 1ojRBN-0003pz-EK for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Oct 2022 22:21:25 +0200 Original-Received: from localhost ([::1]:41182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojRBM-0001Ch-FM for ged-emacs-devel@m.gmane-mx.org; Fri, 14 Oct 2022 16:21:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojR9r-0008Ry-55 for emacs-devel@gnu.org; Fri, 14 Oct 2022 16:19:51 -0400 Original-Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:45839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ojR9p-0005hx-KV for emacs-devel@gnu.org; Fri, 14 Oct 2022 16:19:50 -0400 Original-Received: by mail-pg1-x533.google.com with SMTP id r18so5236080pgr.12 for ; Fri, 14 Oct 2022 13:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=2cCORH4x0NfPZhPbaDoSFV8Yv9b5mUi2XJAglm5+exI=; b=fE8qlRD3Nefl0vw5Cewiag9ANlzVyuQ6Hy8ZJ36OES/OwNQTIlhgo1gv8n6pW6ouAT 9jlOL7hDHlfPjaaQ7732zxp+7bQaBJWbQRhwXKj2V9KnqqZRRC2LQACvilQcHGu0wmwg GEE+ynvfX1cybsQ3qkbCq0/8bPRx8cFGgkodJ0lReSihVEGoyMR9wCwyPduuejzDghXi J6yaxya4Orr1CSlhPe6eBEQVjZVbqxBHITmrmArIiFKdy/D8IwEqfIwO0ja9LJM3duon w8jWWgCy1Wfdxyv8/CmCXfEXAGz7uEEm9gT0ji3GiI0k/4g6gokTt1tViIcpH02uf8Jc MxVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=2cCORH4x0NfPZhPbaDoSFV8Yv9b5mUi2XJAglm5+exI=; b=ko5MgnuzvgXPLOX0aufUPLsGPjl+DZ8PbxE6Z8qi4R+weAjBkFBLuKUsrFm2bNxiCj VdBD3DlpzHW+DWMMJPFCaFp3ib0IruW/1kYST7aqQLIEuFyY0KwJeqgW19oZ/oYJlvcC T5W1Y0kAzZArYJ6zpa6RCiQWtZFaUUyfMMU8uKnG8HimJdapSQ9lSqiKpxyg9IZ1qiyS aKY390eS6r7shw0g4FwTl00/9QYvt39sS+Sk0MPMAqMa33DycLznqiMA5CdUNvHj1cKM o8DWwZqp5D1ToVqRWKo/pBkKf18cwCCpd/eOtwfjZMBjMOsjPBdX14u02yw84gsa8WP8 74Eg== X-Gm-Message-State: ACrzQf2jhQvAClzViAtE6qMzrurzUYhiKizfqAjMIDGxL3hYnXE/C47Z zJQu1cdWo3ai1uxECAwbc50= X-Google-Smtp-Source: AMsMyM4IkDi3aIpckh9hJM9YptVVyH1vcVzmpjmbBjeusjwIyH39jBGbjxcSqG/FoiqLXUNp4CgBtw== X-Received: by 2002:a63:a548:0:b0:462:9d00:1835 with SMTP id r8-20020a63a548000000b004629d001835mr5928446pgu.442.1665778788082; Fri, 14 Oct 2022 13:19:48 -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 n5-20020a170902e54500b0017f73dc1549sm2073604plf.263.2022.10.14.13.19.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Oct 2022 13:19:47 -0700 (PDT) In-Reply-To: <87v8ombrd2.fsf@gnus.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=casouri@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:297734 Archived-At: > On Oct 14, 2022, at 4:02 AM, Lars Ingebrigtsen wrote: >=20 > Yuan Fu writes: >=20 >> Ok, so to make it concrete, in addition to treesit-mode and >> global-treesit-mode, we would have >>=20 >> treesit-major-mode-remap-alist: same as major-mode-remap-alist, >> appended to major-mode-remap-alist when global-treesit-mode turns on. >=20 > Yup. Thinking more about it, there are some problems need to be resolved: - when does xxx-mode.el set treesit-major-mode-remap-alist? = Require-time? That=E2=80=99 seems too late: M-x xxx-mode (autoloader) -> = (require =E2=80=98xxx-mode) -> added to treesit-major-mode-remap-alist = -> ? - If global-treesit-mode is already on, changing = treesit-major-mode-remap-alist doesn=E2=80=99t do anything, you need to = toggle global-treesit-mode for it to take effect. >=20 >> treesit-toggle-function: A function treesit-mode calls to enable >> tree-sitter support, major modes set this function. >=20 > Hm... I'm not sure. A mode like python-mode which has both treesit = and > non-treesit code paths would just be >=20 > (if treesit-mode > (do-one-thing) > (do-the-old-thing)) >=20 > I think? On the other hand, that wouldn't allow dynamic switching > between treesit and non, so perhaps we should have something like = that; > yes. As I said in the previous message, setting treesit-mode locally in major = mode hook doesn=E2=80=99t do anything, because the hook runs after all = the setup. >=20 >> I have yet to come up a way to combine the minor-mode machinery with >> the ability to specify backend for each feature (imenu, xref, >> font-lock, etc). >>=20 >> Maybe we can have something like >>=20 >> feature-provider-alist: An buffer-local alist of (FEATURE . >> PROVIDERS), FEATURE could be indent, font-lock, imenu, xref, etc, >> PROVIDERS is a list of treesit, eglot, emacs, etc. >>=20 >> But I failed to see how to integrate it with the rest. >>=20 >> I wonder if we can have a major mode hook that runs before the body >> runs, like xxx-mode-before-hook. Then user can set >> feature-provider-alist in that hook. This way major modes can decide >> what backend (provider) to use for each features. >=20 > Hm... Emm=E2=80=A6 Yuan