GNU bug report logs - #61043
30.0.50; `json-ts-mode': invalid font lock rule

Previous Next

Package: emacs;

Reported by: Mickey Petersen <mickey <at> masteringemacs.org>

Date: Tue, 24 Jan 2023 20:10:02 UTC

Severity: normal

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Theodor Thornhill <theo <at> thornhill.no>
To: Mickey Petersen <mickey <at> masteringemacs.org>
Cc: 61043 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: bug#61043: 30.0.50; `json-ts-mode': invalid font lock rule
Date: Wed, 25 Jan 2023 14:14:11 +0100

On 25 January 2023 13:09:08 CET, Mickey Petersen <mickey <at> masteringemacs.org> wrote:
>
>Theodor Thornhill <theo <at> thornhill.no> writes:
>
>> Mickey Petersen <mickey <at> masteringemacs.org> writes:
>>
>>> Dmitry Gutov <dgutov <at> yandex.ru> writes:
>>>
>>>> On 24/01/2023 22:09, Mickey Petersen wrote:
>>>>> There's a comment font lock rule in `json-ts-mode'. However, that is
>>>>> illegal and againt the JSON spec, and indeed the search query fails
>>>>> because `comment' is not a valid node type.
>>>>
>>>> When you say it fails, how does that look to you?
>>>>
>>>> Here's an example of a JSON file (or, more accurately, a JSON-superset
>>>> file) with comments:
>>>> https://raw.githubusercontent.com/huytd/vscode-espresso-tutti/master/themes/Espresso%20Tutti-color-theme.json
>>>>
>>>> The JSON tree-sitter grammar seems to parse them correctly as comments
>>>> ("comment" node type), and json-ts-mode highlights them as comments
>>>> correctly as a result.
>>>
>>> It may well be my JSON grammar file that is different then. Which is
>>> perhaps even worse: it is easy to find yourself with one of two
>>> versions.
>>
>>
>> See [0], it seems comment is supported if I'm not mistaken.
>>
>> Theo
>>
>> [0]: https://github.com/tree-sitter/tree-sitter-json/blob/master/grammar.js#L6
>
>I understand. But nevertheless, I do get an error for that rule as it's missing (for some inexplicable reason.)
>
>It would be better if the font lock machinery disables/ignores the rule if it encounters a validation error. That way it'll gracefully degrade.
>

Yeah but this touches a deeper point, imo.

There's no good way to version this. Perhaps when we stop committing treesit stuff to emacs-29 we create a list of verified git commit hashes that are supported by the mode? That way we at least have _some_ info.

What do you think?

Theo




This bug report was last modified 2 years and 144 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.