From: Yuan Fu Date: Wed, 21 Dec 2022 05:21:48 +0000 (-0800) Subject: ; Fix treesit--defuns-around X-Git-Tag: emacs-29.0.90~1047^2~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=69123d4aa4e8a116d4fe328146af5829f3790fc7;p=emacs.git ; Fix treesit--defuns-around Now it doesn't move point. * lisp/treesit.el (treesit--defuns-around): Wrap some code with save-excursion. --- 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))))