emacs-devel
[Top][All Lists]
Advanced

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

Re: Detecting tree-sitter based major-modes for end-user customization a


From: Jostein Kjønigsen
Subject: Re: Detecting tree-sitter based major-modes for end-user customization and third party functions/packages
Date: Tue, 20 Dec 2022 21:14:03 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

On 20.12.2022 21:03, Stefan Monnier wrote:
(treesit-parser-list) seems like a good first approximation, tho I guess
it depends exactly what they want to do with that info.
That name isn't very intuitive for what it does,
AFAIK what it does is return a list of parsers currently setup in the
buffer, so its name seems very intuitive.

Maybe you're thinking of using it for some other purpose?
If so, please describe which one.


        Stefan

At this point treesitter is new, and I'm interested in investigating its general capabilities outside of specific major-modes.

Take for instance the ability to paredit-like navigate up the current parse-tree, regardless of major-mode, as long as it uses tree-sitter.

Something like the code below:

(defun my-auto-parent ()
  (interactive)
  (when (treesit-parser-list)
    (goto-char (treesit-node-start (treesit-node-parent (treesit-node-at (point)))))))

Basically I just want a true or false check for if I'll be able to move on to using treesit-* functionality, or possibly using that specifically in my hooks to replace "primitive" functions and bindings with tree-aware functions instead.

Like I said, (treesit-parser-list) does indeed work, but in a case like this where you don't really care about what parser is being used, only that -a- parser is being used, a simpler, more appropriately named function might be beneficial.

Just my 2 cents.

--
Jostein


reply via email to

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