GNU bug report logs -
#62204
30.0.50; Feature Request: treesit-major-mode-hook
Previous Next
Full log
View this message in rfc822 format
Yuan Fu <casouri <at> gmail.com> writes:
> IIUC, you are trying to do something like
>
> (er/enable-mode-expansions 'clojure-mode 'er/add-clojure-mode-expansions)
>
> right?
Yes!
> But a tree-sitter-based expander doesn’t really depend on any particular
> major mode. In essence, they depend on the existence of a tree-sitter
> parser in the current buffer. So I suggest that you define a universal
> expander (similar to er/expand-word, etc) that checks the existence of a
> tree-sitter parser and uses the parser to expand the region, and simply
> do nothing if there isn’t a parser.
That's exactly what I did. However, instead of having an expander check
every time whether there's a tree-sitter parser, a check that's
redundant past the first one, I wanted to only load that expander
whenever it makes sense and not even call it otherwise. I feel that
makes the code easier to follow, and it makes more sense for the domain.
> But to work with tree-sitter, expand-region might need to disable some
> of its expanders when a tree-sitter parser is available, in case there’s
> some conflict between the existing language-specific expander and the
> tree-sitter expander.
Yes, it's not quite straight-forward, but that's a discussion for the PR
I opened against expand-region.
Thanks for your insight!
Aleks
This bug report was last modified 2 years and 153 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.