>>> 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. > > Is it? > I can't find any code out there that seems to care what is its default > value (all users set it but doesn't look at it, AFAICT). This case looks problematic: ;; LANG can be nil. We don't want to use the fallback ;; in `treesit-language-at', so here we call ;; `treesit-language-at-point-function' directly. (let* ((lang (and treesit-language-at-point-function (funcall treesit-language-at-point-function pos))) But I believe this whole 'let*' can be replaced by just the 'treesit-parsers-at' call. I hope Yuan could confirm this. >> I already tried to do the same by adding 'forward-sexp-default-function' >> to 'forward-sexp-function', but failed spectacularly (bug#70426), > > Yes, that one is much harder (it's one of the first I tried to change), If no more code outside relies on the default value, the default function could be added like this: