From 69123d4aa4e8a116d4fe328146af5829f3790fc7 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Tue, 20 Dec 2022 21:21:48 -0800 Subject: [PATCH] ; Fix treesit--defuns-around Now it doesn't move point. * lisp/treesit.el (treesit--defuns-around): Wrap some code with save-excursion. --- lisp/treesit.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 64076691186..e4f3698dcd9 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1657,10 +1657,13 @@ REGEXP and PRED are the same as in `treesit-defun-type-regexp'." ;; defun, in that case we want to use a node that's actually ;; before/after point. (node-before (if (>= (treesit-node-start node) pos) - (treesit-search-forward-goto node "" t t t) + (save-excursion + (treesit-search-forward-goto node "" t t t)) node)) (node-after (if (<= (treesit-node-end node) pos) - (treesit-search-forward-goto node "" nil nil t) + (save-excursion + (treesit-search-forward-goto + node "" nil nil t)) node)) (result (list nil nil nil)) (pred (or pred (lambda (_) t)))) -- 2.39.2