GNU bug report logs - #78402
treesit after-change-functions

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 13 May 2025 06:34:02 UTC

Severity: normal

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 78402 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: bug#78402: treesit after-change-functions
Date: Sat, 17 May 2025 17:12:25 -0400
> Btw, what’s the issue we’re trying to fix here? If some lisp want to have
> up-to-date ranges, it can just call treesit--pre-redisplay or
> treesit-update-ranges. Why do we get the node-outdated error?

Hmm... so what you're saying is that we should do something like the
patch below?


        Stefan


diff --git a/lisp/treesit.el b/lisp/treesit.el
index a353bc942d3..0c368de6a03 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -4050,6 +4050,9 @@ treesit-outline-search
   "Search for the next outline heading in the syntax tree.
 For BOUND, MOVE, BACKWARD, LOOKING-AT, see the descriptions in
 `outline-search-function'."
+  (if backward
+      (treesit-update-ranges bound (point))
+    (treesit-update-ranges (point) bound))
   (if looking-at
       (when (treesit-outline--at-point) (pos-bol))
 
@@ -4136,11 +4139,6 @@ treesit-outline-level
 
     level))
 
-(defun treesit--after-change (beg end _len)
-  "Force updating the ranges in BEG...END.
-Expected to be called after each text change."
-  (treesit-update-ranges beg end))
-
 ;;; Hideshow mode
 
 (defun treesit-hs-block-end ()
@@ -4438,8 +4436,7 @@ treesit-major-mode-setup
       (setq treesit-outline-predicate
             #'treesit-outline-predicate--from-imenu))
     (setq-local outline-search-function #'treesit-outline-search
-                outline-level #'treesit-outline-level)
-    (add-hook 'outline-after-change-functions #'treesit--after-change nil t))
+                outline-level #'treesit-outline-level))
 
   ;; Remove existing local parsers.
   (dolist (ov (overlays-in (point-min) (point-max)))





This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.