bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun


From: Eli Zaretskii
Subject: bug#59662: 29.0.50; [PATCH] Add treesit--indent-defun
Date: Thu, 08 Dec 2022 12:39:34 +0200

> From: Theodor Thornhill <theo@thornhill.no>
> Cc: dgutov@yandex.ru, monnier@iro.umontreal.ca, larsi@gnus.org,
>  59662@debbugs.gnu.org, casouri@gmail.org
> Date: Thu, 08 Dec 2022 09:56:44 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > My point is that tree-sitter in many cases parses the program better
> > than syntax-ppss.  So if we can use its information about comments and
> > strings, why not do that?  It's exactly the same logic that Dmitry
> > used:
> >
> 
> Something like this?  If we add a defvar such as the below, similar to
> treesit-defun-type-regexp we can use that in the function below:
> 
> ```
> (defvar-local treesit-comment-type-regexp nil
>   "A regexp that matches the node type of comment nodes.
> 
> 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?

> The error handling here is naive, but is this something in the line of
> what you're suggesting?

Yes, it is what I had in mind, but see above.





reply via email to

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