From: Yuan Fu Date: Mon, 24 Oct 2022 01:54:12 +0000 (-0700) Subject: * lisp/treesit.el (treesit-node-at): Remove argument LARGEST. X-Git-Tag: emacs-29.0.90~1792 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6203b9db347d2d002c0cb660d5b4daeea54bf3ad;p=emacs.git * 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. --- diff --git a/lisp/treesit.el b/lisp/treesit.el index 0df9b6c6876..a3bc1259b13 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.