[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: toml-ts-mode: first draft
From: |
Rudi Schlatte |
Subject: |
Re: toml-ts-mode: first draft |
Date: |
Tue, 13 Dec 2022 15:22:11 +0100 |
> On 13 Dec 2022, at 14:20, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Rudolf Schlatte <rudi@constantly.at>
>> Date: Tue, 13 Dec 2022 11:45:42 +0100
>>
>> Yuan Fu <casouri@gmail.com> writes:
>>
>>>
>>> + (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
>>> ;-)
>>
>> I'd expect predicates (functions ending -p) to return T or NIL only and
>> not have side effects.
>
> Did you read the doc string of this function? I think it explains why
> this predicate can sometimes emit a warning and sometimes not. It has
> more than one modus operandi.
[Attention conservation notice: this is only nitpicking about a function name;
please do feel free to not answer this message]
The current docstring (as in the end of this mail) tells me that this predicate
takes a second argument and has various side effects, and I can see how all
these behaviors are useful. But it seems the authors of a number of tree
sitter-using modes did something like
(unless (treesit-ready-p ‘my-language)
(warn “Didn’t find tree-sitter”))
which tells me that the authors expected treesit-ready-p to behave like other
predicate functions, i.e., return NIL or T without side effects. I theorize
that this will be a recurring issue, and that using a function name not ending
in `-p’ (e.g., (treesit-ensure-ready ‘my-language ‘message)) would remove this
millimeter-high barrier. But again: nitpicking, please ignore freely :)
Rudi
"Check whether tree-sitter is ready to be used for MODE and LANGUAGE.
LANGUAGE is the language symbol to check for availability.
It can also be a list of language symbols.
If tree-sitter is not ready, emit a warning and return nil. If
the user has chosen to activate tree-sitter for LANGUAGE and
tree-sitter is ready, return non-nil. If QUIET is t, don't emit
a warning in either case; if quiet is `message', display a message
instead of emitting a warning.”
- Re: toml-ts-mode (code-review done), (continued)
- Re: toml-ts-mode (code-review done), Yuan Fu, 2022/12/14
- Re: toml-ts-mode (code-review done), Jostein Kjønigsen, 2022/12/14
- Re: toml-ts-mode (code-review done), Randy Taylor, 2022/12/14
- Re: toml-ts-mode (code-review done), Jostein Kjønigsen, 2022/12/15
- Re: toml-ts-mode (code-review done), Theodor Thornhill, 2022/12/15
- Re: toml-ts-mode (code-review done), Jostein Kjønigsen, 2022/12/15
- Re: toml-ts-mode (code-review done), Eli Zaretskii, 2022/12/15
- Re: toml-ts-mode (code-review done), Jostein Kjønigsen, 2022/12/15
- Re: toml-ts-mode: first draft, Rudolf Schlatte, 2022/12/13
- Re: toml-ts-mode: first draft, Eli Zaretskii, 2022/12/13
- Re: toml-ts-mode: first draft,
Rudi Schlatte <=