[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/tree-sitter 6203b9db34 7/7: * lisp/treesit.el (treesit-node-at):
From: |
Yuan Fu |
Subject: |
feature/tree-sitter 6203b9db34 7/7: * lisp/treesit.el (treesit-node-at): Remove argument LARGEST. |
Date: |
Sun, 23 Oct 2022 22:07:04 -0400 (EDT) |
branch: feature/tree-sitter
commit 6203b9db347d2d002c0cb660d5b4daeea54bf3ad
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
* lisp/treesit.el (treesit-node-at): Remove argument LARGEST.
LARGEST returns the root node at BOB, finding the smallest node at
point and search upward is a better practice.
---
lisp/treesit.el | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 0df9b6c687..a3bc1259b1 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -101,7 +101,7 @@ Return the root node of the syntax tree."
(treesit-parser-language
(treesit-node-parser node)))
-(defun treesit-node-at (pos &optional parser-or-lang named largest strict)
+(defun treesit-node-at (pos &optional parser-or-lang named strict)
"Return the smallest node that starts at or after buffer position POS.
\"Starts at or after POS\" means the start of the node is greater or
@@ -114,9 +114,6 @@ If PARSER-OR-LANG is nil, use the first parser in
that parser; if PARSER-OR-LANG is a language, find a parser using
that language in the current buffer, and use that.
-If LARGEST is non-nil, return the largest node instead of the
-smallest.
-
If POS is after all the text in the buffer, i.e., there is no
node after POS, return the last leaf node in the parse tree, even
though that node is before POS. If STRICT is non-nil, return nil
@@ -140,13 +137,7 @@ in this case."
(while (setq next (treesit-node-child node -1 named))
(setq node next))
node)
- ;; If LARGEST non-nil, find the largest node that has the same
- ;; starting point as NODE.
- (if (not largest)
- node
- (treesit-parent-while
- node (lambda (n) (eq (treesit-node-start n)
- (treesit-node-start node)))))))))
+ node))))
(defun treesit-node-on (beg end &optional parser-or-lang named)
"Return the smallest node covering BEG to END.
- feature/tree-sitter updated (3114eb8078 -> 6203b9db34), Yuan Fu, 2022/10/23
- feature/tree-sitter 6203b9db34 7/7: * lisp/treesit.el (treesit-node-at): Remove argument LARGEST.,
Yuan Fu <=
- feature/tree-sitter 524d10c86b 3/7: Make treesit-node-at return the last leaf node at EOB, Yuan Fu, 2022/10/23
- feature/tree-sitter 6cf2a9c55d 4/7: Make treesit-search-forward-goto accept a NODE argument, Yuan Fu, 2022/10/23
- feature/tree-sitter c120b0ebdb 5/7: Fix treesit-beginning/end-of-defun, Yuan Fu, 2022/10/23
- feature/tree-sitter e45d8dbeea 1/7: ; * lisp/treesit.el (treesit-range-functions): Fix typo., Yuan Fu, 2022/10/23
- feature/tree-sitter 591759d508 2/7: Make treesit-node-child and fiends accept negative index, Yuan Fu, 2022/10/23
- feature/tree-sitter 1787e651d3 6/7: * lisp/treesit.el (treesit-parser-range-on): New function., Yuan Fu, 2022/10/23