Subject: Re: bug#77256: Treesit language-at-point

From: Juri Linkov <[email-masked]>
Date: Tue, 08 Apr 2025 21:43:20 +0300

>>>   (if treesit-language-at-point-function
>>>       (funcall treesit-language-at-point-function position)
>
> BTW, can we please avoid this anti-pattern?
> Instead, we should unconditionally call
> `treesit-language-at-point-function` and give a non-nil default value to
> this variable.
>
> This would make sure the `treesit-language-at-point-function` is good
> enough to implement the default behavior and it makes it possible to use
> `add-function` on `treesit-language-at-point-function`.

Unfortunately, it's too late to add a non-nil default value.

I already tried to do the same by adding 'forward-sexp-default-function'
to 'forward-sexp-function', but failed spectacularly (bug#70426),
because there are existing uses that expect the default value to be nil.