unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill <theo@thornhill.no>
To: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>,
	"Yuan Fu" <casouri@gmail.com>,
	jostein@kjonigsen.net
Cc: Eli Zaretskii <eliz@gnu.org>, Juri Linkov <juri@linkov.net>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: toml-ts-mode: first draft
Date: Mon, 12 Dec 2022 14:53:23 +0100	[thread overview]
Message-ID: <871qp4iv8s.fsf@thornhill.no> (raw)
In-Reply-To: <32da41dd-2a6e-0a6b-169c-4dc48c2ccb57@secure.kjonigsen.net>

Jostein Kjønigsen <jostein@secure.kjonigsen.net> 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”))
>>
>> Treesit-ready-p already raises a warning when something goes wrong. So you 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 
> tree-sitter based major-modes.
>
>  From json-ts-mode.el:
>
>  >  (unless (treesit-ready-p 'json)
>  >   (error "Tree-sitter for JSON isn't available"))
>
>  From csharp-mode.el:
>
>  >  (unless (treesit-ready-p 'c-sharp)
>  >    (error "Tree-sitter for C# isn't available"))
>
>  From typescript-ts-mode.el:
>
>  >  (when (treesit-ready-p 'tsx)
>  >    (treesit-parser-create 'tsx)
>
>  From python.el:
>
>  >  (when (treesit-ready-p 'python)
>  >    (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



  reply	other threads:[~2022-12-12 13:53 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11 13:28 toml-ts-mode: first draft Jostein Kjønigsen
2022-12-11 17:09 ` Juri Linkov
2022-12-11 17:23   ` Jostein Kjønigsen
2022-12-11 17:40   ` Eli Zaretskii
2022-12-11 18:19     ` Stefan Kangas
2022-12-11 18:23       ` Eli Zaretskii
2022-12-11 21:43         ` Stefan Kangas
2022-12-12  3:28           ` Eli Zaretskii
2022-12-12 17:04       ` Juri Linkov
2022-12-11 19:56     ` Jostein Kjønigsen
2022-12-11 20:07       ` Eli Zaretskii
2022-12-11 20:31         ` Jostein Kjønigsen
2022-12-11 20:38           ` Eli Zaretskii
2022-12-11 20:49             ` Jostein Kjønigsen
2022-12-11 23:01       ` Yuan Fu
2022-12-12 13:10         ` Jostein Kjønigsen
2022-12-12 13:53           ` Theodor Thornhill [this message]
2022-12-12 20:41         ` Jostein Kjønigsen
2022-12-12 21:17           ` Randy Taylor
2022-12-13 20:43             ` Jostein Kjønigsen
2022-12-13 22:37               ` Randy Taylor
2022-12-14  8:40                 ` Jostein Kjønigsen
2022-12-14 13:24                   ` Randy Taylor
2022-12-14 18:53                     ` toml-ts-mode (code-review done) Jostein Kjønigsen
2022-12-14 19:02                       ` Theodor Thornhill
2022-12-14 20:37                         ` Yuan Fu
2022-12-14 22:02                           ` Jostein Kjønigsen
2022-12-15  2:24                             ` Randy Taylor
2022-12-15 12:52                               ` Jostein Kjønigsen
2022-12-15 13:22                                 ` Theodor Thornhill
2022-12-15 13:45                                   ` Jostein Kjønigsen
2022-12-15 14:22                                     ` Eli Zaretskii
2022-12-15 14:28                                       ` Jostein Kjønigsen
2022-12-13 10:45         ` toml-ts-mode: first draft Rudolf Schlatte
2022-12-13 13:20           ` Eli Zaretskii
2022-12-13 14:22             ` Rudi Schlatte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871qp4iv8s.fsf@thornhill.no \
    --to=theo@thornhill.no \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jostein@kjonigsen.net \
    --cc=jostein@secure.kjonigsen.net \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).