Function: treesit-fill-reindent-defun

treesit-fill-reindent-defun is an interactive and byte-compiled function defined in treesit.el.gz.

Signature

(treesit-fill-reindent-defun &optional JUSTIFY)

Documentation

Refill/reindent the paragraph/defun that contains point.

This is a tree-sitter implementation of prog-fill-reindent-defun.

treesit-major-mode-setup assigns this function to prog-fill-reindent-defun-function if the major mode defines the defun thing.

JUSTIFY is the same as in fill-paragraph.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
;;; Prog mode

(defun treesit-fill-reindent-defun (&optional justify)
  "Refill/reindent the paragraph/defun that contains point.

This is a tree-sitter implementation of `prog-fill-reindent-defun'.

`treesit-major-mode-setup' assigns this function to
`prog-fill-reindent-defun-function' if the major mode defines the
`defun' thing.

JUSTIFY is the same as in `fill-paragraph'."
  (interactive "P")
  (save-excursion
    (if (prog--text-at-point-p)
        (fill-paragraph justify (region-active-p))
      (let* ((treesit-defun-tactic 'parent-first)
             (node (treesit-defun-at-point)))
        (indent-region (treesit-node-start node)
                       (treesit-node-end node)
                       nil)))))