emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 09b5f00613: ; Fix calls to treesit functions


From: Theodor Thornhill
Subject: Re: master 09b5f00613: ; Fix calls to treesit functions
Date: Mon, 19 Dec 2022 15:51:22 +0100

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Theodor Thornhill <theo@thornhill.no>
>> Cc: emacs-devel@gnu.org, monnier@iro.umontreal.ca
>> Date: Mon, 19 Dec 2022 14:47:24 +0100
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> >> Date: Mon, 19 Dec 2022 07:26:35 +0100
>> >> From: Theodor Thornhill <theo@thornhill.no>
>> >> 
>> >> How about treesit-ensure, that checks treesit-available-p and whether 
>> >> it's enabled for the current mode? The treesit-parser-list is also kind 
>> >> of working just by accident, as it isn't its job to ensure availability.
>> >
>> > Isn't that what treesit-language-available-p already does?
>> 
>> Yeah, but I don't want to check for a particular language, only that
>> subsequent calls to treesit-functions will be available.
>
> You said:
>
>   How about treesit-ensure, that checks treesit-available-p and
>   whether it's enabled for the current mode?
>
> If this check is for the current mode, then you already have the
> "particular language", don't you?
>
> And that is eventually the right test, because even if the tree-sitter
> library is compiled in and available, the grammar library might not
> be, which means the code cannot use tree-sitter in such a situation.

Yeah, but in for example prog-mode I then have to do something like
(treesit-language-available-p (treesit-language-at (point)))

Which seems long.  IIRC I used something similar in an earlier patch,
and was dismissed because it should have its own api?

```
  (interactive "P")
  (save-excursion
    (if (or (and (treesit-available-p)
                 (treesit-ready-p (treesit-language-at (point)))
                 (string-match-p
                  treesit-comment-type-regexp
```

>>> For example, \"(line|block)_comment\". ")

>> The intent is that major modes set this variable?  SGTM.

>     (if (or (and (treesit-available-p)
>                  (treesit-ready-p (treesit-language-at (point)))

>> I'd imagine that this kind of test should have an API, so the
>> treesit-ready-p call should not be made explicitly?  Yuan, WDYT?
>> Also, isn't it enough to check whether the buffer has a tree-sitter
>> parser or something?

Theo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]