From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill Newsgroups: gmane.emacs.devel Subject: Re: toml-ts-mode: first draft Date: Mon, 12 Dec 2022 14:53:23 +0100 Message-ID: <871qp4iv8s.fsf@thornhill.no> References: <4E261A68-AB14-48A5-B19C-8981CB003F33@secure.kjonigsen.net> <86a63unfvp.fsf@mail.linkov.net> <83cz8pu9cr.fsf@gnu.org> <0f74be1a-8502-ce66-6101-2b3f060295c5@secure.kjonigsen.net> <7825A406-3F21-4E38-9E9B-B429B9E81B4E@gmail.com> <32da41dd-2a6e-0a6b-169c-4dc48c2ccb57@secure.kjonigsen.net> 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="26011"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Juri Linkov , emacs-devel To: Jostein =?utf-8?Q?Kj=C3=B8nigsen?= , Yuan Fu , jostein@kjonigsen.net Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 12 14:55:06 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 1p4jGr-0006W5-7l for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Dec 2022 14:55:05 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4jFv-00063T-24; Mon, 12 Dec 2022 08:54:07 -0500 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 1p4jFX-0005wK-38 for emacs-devel@gnu.org; Mon, 12 Dec 2022 08:53:55 -0500 Original-Received: from out-151.mta0.migadu.com ([2001:41d0:1004:224b::97]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4jFM-000355-CH for emacs-devel@gnu.org; Mon, 12 Dec 2022 08:53:39 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670853206; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5iUC5TTPdqqKVA/v0RpvNFla95W62rOd7uhq6C47h80=; b=UiKTXtJcDu56hVQ+L5HMb2Z1Gh/VddhOKoRYxxVqbG8AnkmdcutdOroo8+k6HEiXDGf3VR swsKExQ4ugsKjG9oL9Vz4zxk1L5+dwpN+KM7075jXvEkpe8aXpi8JFrMkfXtQNZXzQncgA NHroFLWIhYCUrxhvJgVnL2h12NrEvgnRSwPOqilbViLrZfnkXR12OXk2rUHSN8mXVY38iG fvIZuidSiBep2XHcGZUuuIg6XUDx4yOoqWmYAm6rt5u0qLwPLmdRBnoczqXW789bT4wKzU S6Cm20iobcGGVF8ZD8TLIMS97LtID7Lfv2hs6VEY12Bp1qfOAT0bzQG3OEAUbQ== In-Reply-To: <32da41dd-2a6e-0a6b-169c-4dc48c2ccb57@secure.kjonigsen.net> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:1004:224b::97; envelope-from=theo@thornhill.no; helo=out-151.mta0.migadu.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, 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301229 Archived-At: Jostein Kj=C3=B8nigsen writes: > On 12.12.2022 00:01, Yuan Fu wrote: >> Looks great! > Thanks! >> + (unless (treesit-ready-p 'toml) >> + (error "Tree-sitter for TOML isn't avilable=E2=80=9D)) >> >> Treesit-ready-p already raises a warning when something goes wrong. So y= ou want to either pass the QUIET argument or let it do the barking ;-) >> >> Yuan > > Sure, I can fix that. > > I notice though that this is not applied consistently in the other=20 > tree-sitter based major-modes. > > From json-ts-mode.el: > > >=C2=A0 (unless (treesit-ready-p 'json) > > =C2=A0 (error "Tree-sitter for JSON isn't available")) > > From csharp-mode.el: > > >=C2=A0 (unless (treesit-ready-p 'c-sharp) > >=C2=A0=C2=A0=C2=A0 (error "Tree-sitter for C# isn't available")) > > From typescript-ts-mode.el: > > >=C2=A0 (when (treesit-ready-p 'tsx) > >=C2=A0=C2=A0=C2=A0 (treesit-parser-create 'tsx) > > From python.el: > > >=C2=A0 (when (treesit-ready-p 'python) > >=C2=A0=C2=A0=C2=A0 (treesit-parser-create 'python) > > I see in the (treesit-ready-p) it clearly throws when language is missing. > > So from what I can tell all of the "established" forms are doing too much: > > * checking return-value (not required because of throwing) > * creating errors IIRC I had some issues with that form some time in the past. I think we should abstract this away completely and let treesit-major-mode-setup do it, by doing something like: ``` (treesit-major-mode-setup 'java) ``` and inside of that function do the (when (treesit-ready-p lang) (treesit-parser-create lang) ....) Then this could be removed from all modes: (unless (treesit-ready-p 'java) (error "Tree-sitter for Java isn't available")) (treesit-parser-create 'java) Most init is just setq-locals anyway. Is there a reason we cannot do that? Theo