Subject: Re: bug#77733: 31.0.50; Issue with treesit-range-settings and multiple grammars

From: Roman Rudakov <[email-masked]>
Date: Mon, 14 Apr 2025 20:35:59 +0200

Juri Linkov <[email-masked]> writes:

>> 3. Remove one of backticks from the first docstring.
>>
>> Expected result: syntax highlighting of the Clojure code is not 
>> affected.
>>
>> Actual result: part of the Clojure code is highlighted with the 
>> face
>> defined for markdown code_span query. Image attached.
>>
>> P.S. There is a possibility that an issue within clojure-ts-mode is 
>> the
>> cause. Any advice on how to resolve this would be 
>> appreciated. Thank you in
>> advance.
>
> Since the expected result is that syntax highlighting of the Clojure 
> code
> should not be affected, then the solution would be to create 
> isolated
> local parsers:
>
> @@ -345,6 +345,7 @@
>    (treesit-range-rules
>     :embed 'markdown-inline
>     :host 'clojure
> +   :local t
>     (clojure-ts--docstring-query '@capture)))
>
>  (defun clojure-ts--font-lock-settings (markdown-available)
> @@ -1380,7 +1381,6 @@
>    (let ((use-markdown-inline (and clojure-ts-use-markdown-inline
>                                    (treesit-ready-p 'markdown-inline 
>                                    t))))
>      (when use-markdown-inline
> -      (treesit-parser-create 'markdown-inline)
>        (setq-local treesit-range-settings 
>        clojure-ts--treesit-range-settings))
>
>      (when (treesit-ready-p 'clojure)
Amazing! I tried to use ':local t' in the range function, but I didn't 
try removing '(treesit-parser-create 'markdown-inline)' line, which 
apparently solves the problem.

Thank you very much for helping, Juri! This bug can be closed.
--
Best regards, Roman