]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix treesit--defuns-around
authorYuan Fu <casouri@gmail.com>
Wed, 21 Dec 2022 05:21:48 +0000 (21:21 -0800)
committerYuan Fu <casouri@gmail.com>
Thu, 22 Dec 2022 08:42:49 +0000 (00:42 -0800)
Now it doesn't move point.

* lisp/treesit.el (treesit--defuns-around): Wrap some code with
save-excursion.

lisp/treesit.el

index 64076691186bcb383c10942c87827bd715f28004..e4f3698dcd9ed893e7882501380e4068ff4a198e 100644 (file)
@@ -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))))