Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ts-fold.el
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,21 @@ If the current node is not folded or not foldable, do nothing."
(mapcar #'cdr)
(mapc #'ts-fold-close)))))

;;;###autoload
(defun ts-fold-close-all-selected (type)
"Fold all foldable syntax nodes corresponding to TYPE in the buffer."
(interactive "SType: ")
(ts-fold--ensure-ts
(let* ((node (tsc-root-node tree-sitter-tree))
(patterns (vector (list type) '@name))
(query (tsc-make-query tree-sitter-language patterns))
(nodes-to-fold (tsc-query-captures query node #'ignore))
)
(thread-last nodes-to-fold
(mapcar #'cdr)
(mapc #'ts-fold-close))
)))

;;;###autoload
(defun ts-fold-open-all ()
"Unfold all syntax nodes in the buffer."
Expand Down