emacs-devel
[Top][All Lists]
Advanced

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

Re: treesit-range-settings with ':local' : I missed something or it's a


From: Vincenzo Pupillo
Subject: Re: treesit-range-settings with ':local' : I missed something or it's a bug?
Date: Mon, 29 Jan 2024 15:04:25 +0100

Hi Yuan,
In data domenica 28 gennaio 2024 08:09:02 CET, Yuan Fu ha scritto:
> 
> Actually, local parsers are not included in the return value of
> (treesit-parser-list). By default, treesit-parser-list returns all the
> parsers whose tag is nil, but all the local parsers carry a tag of
> ‘embedded. To actually return all the parsers in the buffer you need to use
> (treesit-parser-list nil nil t), ie, pass t to the TAG parameter.
> 
> I pulled your php-ts-mode_phpdoc.el and played around with it. I found the
> root cause to be the call to
> 
> (treesit-parser-create ‘phpdoc)
> 
> In the major mode body. This creates a global phpdoc parser that fontifies
> everything in doc face.
> 
> Removing that, plus the fix for #1 that I just pushed to master, should fix
> the font-lock problem you are observing.
It seems to work, but just try to indent the entire buffer, and the problem 
reappears. Before indenting: 
((#<treesit-parser for html> ((1 . 271))) (#<treesit-parser for css> ((161 . 
223))) (#<treesit-parser for javascript> ((73 . 138))) (#<treesit-parser for 
php> nil) (#<treesit-parser for phpdoc> ((517 . 621))) (#<treesit-parser for 
phpdoc> ((672 . 810))) (#<treesit-parser for phpdoc> ((939 . 1032))) 
(#<treesit-parser for phpdoc> ((1157 . 1223))))

after indenting the whole buffer:

((#<treesit-parser for html> ((1 . 271))) (#<treesit-parser for css> ((161 . 
223))) (#<treesit-parser for javascript> ((73 . 138))) (#<treesit-parser for 
php> nil) (#<treesit-parser for phpdoc> ((517 . 621))) (#<treesit-parser for 
phpdoc> ((672 . 810))) (#<treesit-parser for phpdoc> ((939 . 1032))) 
(#<treesit-parser for phpdoc> ((1157 . 1223))) (#<treesit-parser for phpdoc> 
nil))
 
As you can see the list of parsers has changed, and the latest one is:
(#<treesit-parser for phpdoc> nil)  .

To reproduce the problem:
1. open a php file (for e.g. the php file attached)
2. Indent the entire buffer
3. add a comment line inside a document block

The attached screenshot shows the result.
> 
> I couldn’t fine the patch you mentioned in the thread so I don’t know if
> this is what your patch does.

The modification I attached (that's the one I was talking about that I forgot 
to attach) solves the problem, but downstream, not upstream (I am not familiar 
with how treesit.el works). 
> 
> Yuan
Thanks 

V.

Attachment: tressit_indent_font-lock_issue.png
Description: PNG image

Attachment: 0001-Remove-local-parser-from-global-parser-list-when-fon.patch
Description: Text Data

Attachment: index4.php
Description: application/php

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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