diff options
| author | Juri Linkov | 2025-04-08 20:43:41 +0300 |
|---|---|---|
| committer | Juri Linkov | 2025-04-08 20:43:41 +0300 |
| commit | bec2de20469db0767d2bd7f60f0d4dfb20269614 (patch) | |
| tree | b339c970e40e6eebbc4b547de59d4f4e9760227d | |
| parent | 5e0daa1ef77d2a5fe5b65b8f0fa6c4eab83a2498 (diff) | |
| download | emacs-bec2de20469db0767d2bd7f60f0d4dfb20269614.tar.gz emacs-bec2de20469db0767d2bd7f60f0d4dfb20269614.zip | |
* lisp/treesit.el (treesit--after-change): New function.
(treesit-major-mode-setup): Set 'outline-minor-mode-hook'
to add 'treesit--after-change' with 'treesit-update-ranges'
to 'after-change-functions' (bug#77256).
| -rw-r--r-- | lisp/treesit.el | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el index 888f067e0cc..8e57a6dae14 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el | |||
| @@ -4068,6 +4068,10 @@ For BOUND, MOVE, BACKWARD, LOOKING-AT, see the descriptions in | |||
| 4068 | 4068 | ||
| 4069 | level)) | 4069 | level)) |
| 4070 | 4070 | ||
| 4071 | (defun treesit--after-change (beg end _len) | ||
| 4072 | "Force updating the ranges after each text change." | ||
| 4073 | (treesit-update-ranges beg end)) | ||
| 4074 | |||
| 4071 | ;;; Hideshow mode | 4075 | ;;; Hideshow mode |
| 4072 | 4076 | ||
| 4073 | (defun treesit-hs-block-end () | 4077 | (defun treesit-hs-block-end () |
| @@ -4362,7 +4366,16 @@ before calling this function." | |||
| 4362 | (setq treesit-outline-predicate | 4366 | (setq treesit-outline-predicate |
| 4363 | #'treesit-outline-predicate--from-imenu)) | 4367 | #'treesit-outline-predicate--from-imenu)) |
| 4364 | (setq-local outline-search-function #'treesit-outline-search | 4368 | (setq-local outline-search-function #'treesit-outline-search |
| 4365 | outline-level #'treesit-outline-level)) | 4369 | outline-level #'treesit-outline-level) |
| 4370 | (add-hook 'outline-minor-mode-hook | ||
| 4371 | (lambda () | ||
| 4372 | (if (bound-and-true-p outline-minor-mode) | ||
| 4373 | (add-hook 'after-change-functions | ||
| 4374 | #'treesit--after-change | ||
| 4375 | 0 t) | ||
| 4376 | (remove-hook 'after-change-functions | ||
| 4377 | #'treesit--after-change t))) | ||
| 4378 | nil t)) | ||
| 4366 | 4379 | ||
| 4367 | ;; Remove existing local parsers. | 4380 | ;; Remove existing local parsers. |
| 4368 | (dolist (ov (overlays-in (point-min) (point-max))) | 4381 | (dolist (ov (overlays-in (point-min) (point-max))) |