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

From: Stefan Monnier <[email-masked]>
Date: Thu, 17 Apr 2025 11:01:41 -0400

> Ultimately I think you are right that we want guarantee to Lisp programs
> that parser ranges are always up-to-date, so they don’t have to call
> treesit-update-ranges themselves every where. But the exact implementation
> to achieve that is still not super clear in my head. After thinking about
> this more and rewriting this reply three times, I think the best way might
> be to call treesit--pre-redisplay in
> after-change-functions. Treesit--pre-redisplay should make sure all the
> parser ranges are updated. The only thing I don’t like about this is that
> there’re many cases where a series of buffer edits are made, and we don’t
> want to update ranges after each single buffer edit. Post-command-hook
> should prevent that, but post-command-hook feels really user-facing and
> high-level to me.

I don't know how ranges are managed/computed, but the usual way to
handle this kind of problem is to separate the "mark as out of date"
from the actual update which you do only lazily when a request
is made.

        Stefan