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: Tree-sitter api Date: Thu, 16 Sep 2021 23:56:20 -0700 Message-ID: <03386E3C-A975-4ECD-BF89-6AC62F751725@gmail.com> References: <83r1f7hydn.fsf@gnu.org> <8335qbirsr.fsf@gnu.org> <73E0B1F6-6F9F-40E0-927E-D08481BFF391@gmail.com> <834kaqhqlp.fsf@gnu.org> <8335qahqgk.fsf@gnu.org> <3BC29D06-CA75-4706-9AD7-ABA2F65C4DEE@gmail.com> <83v936fj35.fsf@gnu.org> <83r1dselyo.fsf@gnu.org> <6A4CE984-6ACE-4E66-8EF2-F3D351C02248@gmail.com> <83r1dscpt2.fsf@gnu.org> <83o88wcof9.fsf@gnu.org> <83lf3zdh4z.fsf@gnu.org> <8965C4A0-79D3-4D77-A6BA-D07A6C93F7FE@gmail.com> <83ilz3cs4k.fsf@gnu.org> <04D19C1A-CD64-4156-B932-1C9FEEE4EC7B@gmail.com> <83zgsebc0r.fsf@gnu.org> <1F752923-F357-4A18-B6E2-0120F1B9BD37@gmail.com> <83fsu5bzem.fsf@gnu.org> <83zgsdad5j.fsf@gnu.org> <83sfy391ni.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) 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="31152"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?B?VHXhuqVuLUFuaCBOZ3V54buFbg==?= , Theodor Thornhill , =?utf-8?Q?Cl=C3=A9ment_Pit-Claudel?= , Emacs developers , Stefan Monnier , stephen_leake@stephe-leake.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 17 08:57:33 2021 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 1mR7oT-0007x2-HH for ged-emacs-devel@m.gmane-mx.org; Fri, 17 Sep 2021 08:57:33 +0200 Original-Received: from localhost ([::1]:39740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mR7oS-0000zr-1l for ged-emacs-devel@m.gmane-mx.org; Fri, 17 Sep 2021 02:57:32 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mR7nO-0000D3-I1 for emacs-devel@gnu.org; Fri, 17 Sep 2021 02:56:26 -0400 Original-Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:37633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mR7nM-0008B8-Tl; Fri, 17 Sep 2021 02:56:26 -0400 Original-Received: by mail-qk1-x732.google.com with SMTP id 73so9404074qki.4; Thu, 16 Sep 2021 23:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=nfKL9O1WxCOdzqhSvViIS8lA3ROBrhysr3zCZ9fZFgo=; b=CmsBE4Cp0AHiiUotkVsadZpWuvu7frH/3ndaal2ctCKrBR4iWlQCNNLxGXWvnkO8DP yL0xVoiG+mr5QuxZLobnSBSKqopz2fnTv+n5VH4Sv3XW0ptvQsWkajVi+K9LKvRJnfEA uSKxgyM82cY8BNA3KRZHXqHj79pK5UOdbg7yO50vdBSYTKodjNTEbLx7zYTlcEVgrIso iEUncSBRcdGjjjgxGo0+NRAdYkIbK+7rStLPfLESoTYiqsACqsCzdiLbF0zRsijYmC9D 2jFsZiYUZjGJ38/nFujYrplsjPrvzEoLWUyUq0uNDk3OEJYX3r7V/Pu/xemgpH8UlLVT /W5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=nfKL9O1WxCOdzqhSvViIS8lA3ROBrhysr3zCZ9fZFgo=; b=7KFVv8qDI9IBkg3xK3/R0BFsEfh0nI7p7x6xU0qe6bIUKvpXoohGYa3GMcGjjxZ4x0 ec6EpT4hhbQbtJLi6Jwx8Mq3jRsQ6AJCOH6g54cpMdafszFvE1LhwWpi7SU5sSFllsN0 xJfYzYyMkfxMr58IBx0WiwOYT4Qp7tudoN4nqxJAHHa9IhMQoq4PlyffFBHv7yc+kkYV R7uFA+FP+V/YMIVwJnkLFTea4Ar8NHUPS0hcowbxKtrLZNVq+VmVyAM31wOSUZ4ZL5dd ++I8Ofq0usVvqKnZgED3x3vGI6UU9q0C5U7oxmWO2Nl0H+VKhkMtDQC/TYWeeKcGGvok PTGA== X-Gm-Message-State: AOAM5309zJGQGCa6PzFzv9t3iLWIyIpmmxQmvFa1/T04WUTp1xstlEe1 87HJlvWjIaC9wgwJ3WY9sDP08Vmm7bY70g== X-Google-Smtp-Source: ABdhPJyzU5GsGUA3kzv1OTGojv9gd3qG9/Dsk5gKN8JoAyo3TIkZHnso7ornbxP4s7rdeQtdGCMMaw== X-Received: by 2002:a37:b385:: with SMTP id c127mr8957667qkf.206.1631861782545; Thu, 16 Sep 2021 23:56:22 -0700 (PDT) Original-Received: from smtpclient.apple ([2600:1700:2ec7:8c9f:6c2c:1a17:b2af:c864]) by smtp.gmail.com with ESMTPSA id e16sm2402201qkl.117.2021.09.16.23.56.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 23:56:21 -0700 (PDT) In-Reply-To: <83sfy391ni.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=casouri@gmail.com; helo=mail-qk1-x732.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.23 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:274842 Archived-At: >>=20 >> My point is, major mode writers need to read the source of the = tree-sitter language definition to do anything useful with tree-sitter >=20 > If this is so, then why do we bother documenting the Lisp APIs for > TS-related features? If Lisp programmers need to read the TS sources > to do anything useful in Emacs, let them read the sources, including > the Lisp and C sources you are working on? >=20 > That was somewhat sarcastic, but my point is that this is NOT how we > do this kind of stuff in Emacs. We should have Lisp-level facilities > that reflect the TS features, and those Lisp-level facilities should > be documented and should be the ONLY thing a Lisp programmer needs to > read to adapt his/her major mode to TS. We should NOT assume that > Lisp programmers read the TS source code, exactly like we don't assume > that for other libraries, like GnuTLS, librsvg, or libgccjit. Under > that modus operandi, the way to glean the part from the major > mode's language name is something that should be part of the > facilities we provide. Thank you for your patience. I certainly believe in documentation and = put considerable effort into it, and if it is possible to document as = you described, I would do it. We have documentation for all the = tree-sitter features provided by Emacs and a bit more, but I don=E2=80=99t= think it is possible to document the language definitions. We can think = of language definitions as BNF grammars for each language, how do you = document that? Say, for the language definition for Scheme below, how do = we document it? --> | | | | | ( | ) | #( |=20 ' | ` | , | ,@ | . --> | ( | ) | " | ; --> --> ; ... --> | | | =E2=80=A6 The language definition source of a tree-sitter language is basically = that, with some superfluous javascript syntax. Language definitions are = not mechanic, but rather data=E2=80=94you can document mechanic but not = really data. And I want to also point out that as Emacs core developers, we can=E2=80=99= t possibly provide a good translation from convention language names to = their tree-sitter name (C# -> c-sharp). Maybe we can do a half-decent = job, but 1) that won=E2=80=99t cover all available languages, and 2) if = there is a new language, we need to wait for the next release to update = our translation. It is better for the major mode writers to provide the = information on how to translate names. Because, as I said earlier, they = already know it. Yuan=