Function: treesit-indent
treesit-indent is a byte-compiled function defined in treesit.el.gz.
Signature
(treesit-indent)
Documentation
Indent according to the result of treesit-indent-function.
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-indent ()
"Indent according to the result of `treesit-indent-function'."
(treesit-update-ranges (line-beginning-position)
(line-end-position))
;; We don't return 'noindent even if no rules match, because
;; `indent-for-tab-command' tries to indent itself when we return
;; 'noindent, which leads to wrong indentation at times.
(pcase-let* ((`(,anchor . ,offset) (treesit--indent-1)))
(when (and anchor offset)
(let ((col (+ (save-excursion
(goto-char anchor)
(current-column))
offset))
(delta (- (point-max) (point))))
(indent-line-to col)
;; Now point is at the end of indentation. If we started
;; from within the line, go back to where we started.
(when (> (- (point-max) delta) (point))
(goto-char (- (point-max) delta)))))))