Function: treesit-beginning-of-thing
treesit-beginning-of-thing is a byte-compiled function defined in
treesit.el.gz.
Signature
(treesit-beginning-of-thing THING &optional ARG TACTIC)
Documentation
Like beginning-of-defun, but generalized into things.
THING can be a thing defined in treesit-thing-settings, which see,
or a predicate. ARG is the same as in beginning-of-defun.
TACTIC determines how does this function move between things. It
can be nested, top-level(var)/top-level(fun), restricted, or nil. nested
means normal nested navigation: try to move to siblings first,
and if there aren't enough siblings, move to the parent and its
siblings. top-level(var)/top-level(fun) means only consider top-level things, and
nested things are ignored. restricted means movement is
restricted inside the thing that encloses POS (i.e., parent),
should there be one. If omitted, TACTIC is considered to be
nested.
Return non-nil if successfully moved, nil otherwise.
Other relevant functions are documented in the treesit group.
Probably introduced at or before Emacs version 30.1.
Shortdoc
;; treesit
(treesit-beginning-of-thing 'defun 1 'nested)
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-beginning-of-thing (thing &optional arg tactic)
"Like `beginning-of-defun', but generalized into things.
THING can be a thing defined in `treesit-thing-settings', which see,
or a predicate. ARG is the same as in `beginning-of-defun'.
TACTIC determines how does this function move between things. It
can be `nested', `top-level', `restricted', or nil. `nested'
means normal nested navigation: try to move to siblings first,
and if there aren't enough siblings, move to the parent and its
siblings. `top-level' means only consider top-level things, and
nested things are ignored. `restricted' means movement is
restricted inside the thing that encloses POS (i.e., parent),
should there be one. If omitted, TACTIC is considered to be
`nested'.
Return non-nil if successfully moved, nil otherwise."
(pcase-let* ((arg (or arg 1))
(dest (treesit-navigate-thing
(point) (- arg) 'beg thing tactic)))
(when dest
(goto-char dest))))