GNU bug report logs -
#71086
30.0.50; Setting treesit-indent-function is not effective is treesit-simple-indent-rules is nil
Previous Next
Reported by: Óscar Fuentes <ofv <at> wanadoo.es>
Date: Tue, 21 May 2024 01:33:02 UTC
Severity: normal
Found in version 30.0.50
Done: Óscar Fuentes <ofv <at> wanadoo.es>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> From: Óscar Fuentes <ofv <at> wanadoo.es>
> Date: Tue, 21 May 2024 03:32:05 +0200
>
>
> treesit-major-mode-setup setups indentation if and only if
> treesit-simple-indent-rules is non-nil. So the major mode author is
> forced to set that variable even when he makes no use of the
> treesit-simple-indent facilities and instead sets
> treesit-indent-function to his own function.
If your mode defines a treesit-indent-function, why do you need the
help of treesit-major-mode-setup for setting up indentation?
The idea of treesit-simple-indent, AFAIU, is to automate the simple
cases, on the assumption that the mode complex cases cannot be
second-guessed up front, and the mode programmer will need to set that
up manually. For example, you can assign your functions to
indent-line-function and indent-region-function. Or what am I
missing?
> OTOH, the info node for "Parser-based Indentation" says:
>
> To enable the parser-based indentation engine, either set
> ‘treesit-simple-indent-rules’ and call ‘treesit-major-mode-setup’, or
> equivalently, set the value of ‘indent-line-function’ to
> ‘treesit-indent’.
>
> However, treesit-major-mode-setup does more than what's described after
> "equivalently":
>
> (when treesit-simple-indent-rules
> (setq-local treesit-simple-indent-rules
> (treesit--indent-rules-optimize
> treesit-simple-indent-rules))
> (setq-local indent-line-function #'treesit-indent)
> (setq-local indent-region-function #'treesit-indent-region))
So this is just a matter of updating the documentation to mention
indent-region-function?
I've added Yuan, in case he has comments or suggestions.
This bug report was last modified 1 year and 48 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.