Function: treesit-forward-sentence

treesit-forward-sentence is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit-forward-sentence &optional ARG)

Documentation

Tree-sitter forward-sentence-function implementation.

ARG is the same as in forward-sentence.

If point is inside a text environment, go forward a prose sentence using forward-sentence-default-function. If point is inside code, go forward a source code sentence.

What constitutes as text and source code sentence is determined by text and sentence in treesit-thing-settings.

View in manual

Probably introduced at or before Emacs version 30.1.

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-forward-sentence (&optional arg)
  "Tree-sitter `forward-sentence-function' implementation.

ARG is the same as in `forward-sentence'.

If point is inside a text environment, go forward a prose
sentence using `forward-sentence-default-function'.  If point is
inside code, go forward a source code sentence.

What constitutes as text and source code sentence is determined
by `text' and `sentence' in `treesit-thing-settings'."
  (if (treesit-node-match-p (treesit-node-at (point)) 'text t)
      (funcall #'forward-sentence-default-function arg)
    (or (funcall
         (if (> arg 0) #'treesit-end-of-thing #'treesit-beginning-of-thing)
         'sentence (abs arg))
        ;; On failure jump to the buffer's end as `forward-sentence' does,
        ;; but no further than the boundary of the current range.
        (goto-char (if (> arg 0)
                       (min (point-max) (next-single-char-property-change
                                         (point) 'treesit-parser))
                     (max (point-min) (previous-single-char-property-change
                                       (point) 'treesit-parser)))))))