From 9f7c359f4023570616c9961487069ba1122a5bb0 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Fri, 7 Oct 2022 18:06:04 -0700 Subject: [PATCH] Add note on tree-sitter's naming convention * admin/notes/tree-sitter/starter-guide: Add note. * doc/lispref/parsing.texi: Add note. --- admin/notes/tree-sitter/starter-guide | 7 +++++++ doc/lispref/parsing.texi | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/admin/notes/tree-sitter/starter-guide b/admin/notes/tree-sitter/starter-guide index 129f9ee5fa4..378ff581afa 100644 --- a/admin/notes/tree-sitter/starter-guide +++ b/admin/notes/tree-sitter/starter-guide @@ -8,6 +8,7 @@ TOC: - Building Emacs with tree-sitter - Install language definitions - Setup +- Naming convention - Font-lock - Indent - Imenu @@ -94,6 +95,12 @@ Then in other places, we decide on whether to enable tree-sitter by (treesit-can-enable-p)) #+end_src +* Naming convention + +When referring to tree-sitter as a noun, use “tree-sitter”, like +python-use-tree-sitter. For prefix use “treesit”, like +python-treesit-indent. + * Font-lock Tree-sitter works like this: You provide a query made of patterns and diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 3784531fe59..d0bb642a3e0 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -30,6 +30,10 @@ For tree-sitter integration with existing Emacs features, @pxref{Parser-based Font Lock}, @ref{Parser-based Indentation}, and @ref{List Motion}. +About naming convention: use ``tree-sitter'' when referring to it as a +noun, like @code{python-use-tree-sitter}, but use ``treesit'' for +prefixes, like @code{python-treesit-indent-function}. + To access the syntax tree of the text in a buffer, we need to first load a language definition and create a parser with it. Next, we can query the parser for specific nodes in the syntax tree. Then, we can -- 2.39.2