emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 69123d4aa4 1/3: ; Fix treesit--defuns-around


From: Yuan Fu
Subject: emacs-29 69123d4aa4 1/3: ; Fix treesit--defuns-around
Date: Thu, 22 Dec 2022 03:46:23 -0500 (EST)

branch: emacs-29
commit 69123d4aa4e8a116d4fe328146af5829f3790fc7
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    ; 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 6407669118..e4f3698dcd 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))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]