Commit graph

27 commits

Author SHA1 Message Date
Yuan Fu
bb8a46e559
Update tree-sitter manual to reflect the previous commit
* doc/lispref/modes.texi: Update manual to reflect previous change:
remove :toggle and :level, add :feature.  Document new variables and
functions.
* doc/lispref/parsing.texi: Add the missing closing bracket in
@code{(t . nil)}.
2022-10-13 15:09:51 -07:00
Yuan Fu
f0e9085a17
* doc/lispref/parsing.texi: Add manual for treesit-query-language. 2022-10-13 14:40:38 -07:00
Yuan Fu
0b3f785c4a
Better signal data for treesit-load-language-error
* src/treesit.c (ts_load_language): Better formatted signal data,
(Ftreesit_langauge_available_p): Optionally return the signal data if
language not available.
* doc/lispref/parsing.texi: Document the signal data in detail.
2022-10-12 10:38:35 -07:00
Yuan Fu
9f7c359f40
Add note on tree-sitter's naming convention
* admin/notes/tree-sitter/starter-guide: Add note.
* doc/lispref/parsing.texi: Add note.
2022-10-09 17:20:26 -07:00
Yuan Fu
7a4380b905
; * doc/lispref/parsing.texi (Language Definitions): Fix typo. 2022-10-04 13:30:56 -07:00
Yuan Fu
96d44c4321
Add treesit-language-version
* doc/lispref/parsing.texi (Language Definitions): Update manual.
* src/treesit.c (Ftreesit_language_version): New function
2022-10-04 13:30:56 -07:00
Yuan Fu
10f96a8c57
Improve documentation of tree-sitter search functions
* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* src/treesit.c (treesit-search-subtree)
(treesit-search-forwardn)
(treesit-induce-sparse-tree): Mention case-insensitivity.
* lisp/treesit.el (treesit-simple-indent): Mention case-insensitivity.
2022-10-04 13:30:56 -07:00
Yuan Fu
6a3caeab58
Remove treesit-query-in
Because treesit-query-capture can now do everything it does.

* doc/lispref/parsing.texi (Pattern Matching): Update manual.
* lisp/treesit.el (treesit-query-in): Remove function.
* src/treesit.c (Ftreesit_query_capture): Accept parser and language
symbol as NODE.
2022-10-04 13:30:52 -07:00
Yuan Fu
6e60d46418
Fix tree-sitter manuals
* doc/lispref/modes.texi: Fix typos, reword, etc.
* doc/lispref/parsing.texi: Fix typos, reword, etc.
2022-09-30 16:51:21 -07:00
Yuan Fu
ef6e18a6b9
Improve treesit-search-forward-goto
* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* lisp/treesit.el (treesit-search-forward-goto): Instead of taking a
node, use the node at point, and make sure we make progress.
2022-09-24 21:11:31 -07:00
Yuan Fu
eba6582436
Add the treesit-search functions that supplant the removed ones
The signatures also changed.

treesit-traverse-depth-first   -> treesit-search-subtree
treesit-traverse-breadth-first ->
treesit-traverse-forward       -> treesit-search-forward
treesit-search-forward         -> treesit-search-forward-goto
treesit-search-beginning/end   -> treesit-search-forward-goto
                               -> treesit-induce-sparse-tree

* doc/lispref/parsing.texi (Retrieving Node): Add relevant manual
sections.
* lisp/treesit.el (treesit-search-forward-goto): New function.
* src/treesit.c (ts_traverse_sibling_helper)
(ts_traverse_match_predicate)
(ts_search_dfs)
(ts_search_forward)
(treesit-search-subtree)
(treesit-search-forward)
(ts_build_sparse_tree)
(Ftreesit_induce_sparse_tree): Add functions.
* test/src/treesit-tests.el (treesit-node-supplemental): Add comments.
2022-09-24 21:11:30 -07:00
Yuan Fu
c957832cbf
Remove treesit-traverse functions
Remove before adding the replacements.

* doc/lispref/parsing.texi (Retrieving Node): Remove relevant sections.
* lisp/treesit.el (treesit-traverse-depth-first)
(treesit--traverse-breadth-first-1)
(treesit-traverse-breadth-first)
(treesit-next-sibling-or-up)
(treesit-traverse-forward)
(treesit-search-forward)
(treesit-search-beginning):
(treesit-search-end): Remove functions.
(treesit-defun-query): Remove variable.
(treesit-beginning-of-defun)
(treesit-end-of-defun): Remove functions.
* test/src/treesit-tests.el: Remove comments.
2022-09-24 21:11:30 -07:00
Yuan Fu
914f68da05
; Minor tree-sitter manual fix
* doc/lispref/parsing.texi (Retrieving Node): Remove the quote.
2022-09-24 21:11:29 -07:00
Yuan Fu
1d3234988a
Add node-only parameter to treesit-query-capture
* doc/lispref/parsing.texi (Pattern Matching): Mention the new
parameter.
* lisp/treesit.el (treesit-query-in): Add node-only.
* src/treesit.c (Ftreesit_query_capture): Add node-only.
2022-09-08 12:52:25 -07:00
Yuan Fu
c2a9fe0c1d
Fix tree-sitter manual entry for treesit-should-enable-p
* doc/lispref/parsing.texi: Move two entries in the front to "Using
Parser" section, replacing the old entry.
2022-09-07 16:15:01 -07:00
Yuan Fu
a23aec59b3
Remove treesit-disabled-modes and change treesit-should-enable-p
Per emacs-devel discussion, remove treesit-disabled-modes and let
major modes to provide tree-sitter switches.  I also decided to add
treesit-max-buffer-size to elisp manual despite it being a user
option.  Though we should still add it to the user manual.

* doc/lispref/parsing.texi (Parsing Program Source): Update manual to
remove entries for treesit-diabled-modes and add
treesit-max-buffer-size.  Also update treesit-should-enable-p.
* lisp/treesit.el (treesit-disabled-modes): Remove user option.
(treesit-maximum-size): Change to treesit-max-buffer-size.
(treesit-should-enable-p): Change to treesit-can-enable-p and remove
checks of treesit-disabled-modes.
2022-09-07 13:20:37 -07:00
Yuan Fu
31ad906bd0
Add manual entry for tree-sitter search functions
* doc/lispref/parsing.texi (Retrieving Node): New subsection
"Searching for node".
* doc/lispref/positions.texi (List Motion): Add entries for
treesit-defun-query, treesit-beginning-of-defun, treesit-end-of-defun.
* lisp/treesit.el (treesit-search-forward, treesit-search-beginning)
(treesit-search-end): Minor docstring fix-up.
2022-09-07 11:52:13 -07:00
Yuan Fu
e98b4715bb ; * doc/lispref/parsing.texi: Minor touch-up. 2022-08-19 00:33:27 -07:00
Yuan Fu
11379ef236 Remove treesit manual entries for deleted functions
* doc/lispref/parsing.texi: Remove documentation for
treesit-get-parser-create and treesit-get-parser.
2022-08-19 00:26:08 -07:00
Yuan Fu
246dbb540a Change treesit-parser-list from variable to function
Effectively making the list internal.  Now Emacs user cannot shoot
themselves in the foot by removing a parser from the list, make
chaanges to buffer and add that parser back to the list.

* doc/lispref/parsing.texi (Language Definitions, Using Parser)
(Retrieving Node, Multiple Languages): Change variable to function.
* lisp/treesit.el (treesit-language-at, treesit-node-on)
(treesit-buffer-root-node, treesit-indent, treesit-check-indent)
(treesit-search-forward, treesit-search-beginning)
(treesit-end-of-defun, treesit-inspect-mode): Change variable to
function.
* src/buffer.c (bset_ts_parser_list, reset_buffer, init_buffer_once):
Add ts_parser_list.
* src/buffer.h (struct buffer): Add ts_parser_list.
* src/treesit.c (ts_record_change, Ftreesit_parser_create): Use the
buffer field instead of the old buffer local variable.
(Ftreesit_parser_delete, Ftreesit_parser_list): New functions.
(syms_of_treesit): Remove treesit-parser-list.
* test/src/treesit-tests.el (treesit-basic-parsing): Use the new
function.
2022-06-16 17:55:07 -07:00
Yuan Fu
184d212042
Merge branch 'feature/tree-sitter-depth-control' into feature/tree-sitter 2022-06-14 15:52:21 -07:00
Yuan Fu
316bdc334c
Add manual for treesit-traverse-forward and friends
* doc/lispref/parsing.texi (Retrieving Node): Add manual entry for
treesit-traverse-depth-first, treesit-traverse-breadth-first,
treesit-traverse-forward.
* lisp/treesit.el (treesit-traverse-forward): Fix docstring.
2022-06-14 15:49:44 -07:00
Yuan Fu
a7288594f4
Change treesit-check-query and mention it in documentation
* doc/lispref/parsing.texi (Pattern Matching): Mention it.
* lisp/treesit.el (treesit-check-query): Rename to
treesit-query-validate.
* src/treesit.c (Ftreesit_query_capture, Ftreesit_query_compile):
Mention it.
2022-06-14 14:30:39 -07:00
Yuan Fu
296900184d
Add treesit-query-compile to manual
* doc/lispref/parsing.texi: Add treesit-query-compile.
2022-06-14 14:17:17 -07:00
Yuan Fu
016e4ca7a7
; * doc/lispref/parsing.texi: Minor fix-up. 2022-06-14 14:17:08 -07:00
Yuan Fu
78df03329d
Redefine treesit-node-at
The old 'treesit-node-at' becomes 'treesit-node-on'.  The new
'treesit-node-at' has slightly different semantics.  Now
'treesit-node-on' gets the smallest node covering a range and
'treesit-node-at' gets the smallest node after a position.

The reason of change can be found in the docstring of
'treesit-node-on' (the BEWARE part): its result can be sometimes
surprising/unexpected.

* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* lisp/treesit.el (treesit-node-at): Change to new definition.
(treesit-node-on): Inherits the old definition of
'treesit-node-at'.  Parameter END is now mandatory.
(treesit-language-at, treesit-node-field-name): Use the new '-on'
function.
(treesit-font-lock-fontify-region, treesit-simple-indent-presets,
treesit-indent): Use the new '-at' function.
* test/src/treesit-tests.el (treesit-node-supplemental): Update tests.
2022-05-13 14:36:37 -07:00
Yuan Fu
84847cad82
Add tree-sitter intergration
* configure.ac (HAVE_TREE_SITTER, TREE_SITTER_OBJ): New variables.
(DYNAMIC_LIB_SUFFIX): new variable, I copied code from MODULES_SUFFIX
so the diff looks this way.
* doc/lispref/elisp.texi (Top): Add tree-sitter manual.
* doc/lispref/modes.texi (Font Lock Mode): mention tree-sitter.
(Parser-based Font Lock): New section.
(Auto-Indentation): Mention tree-sitter.
(Parser-based Indentation): New section.
* doc/lispref/parsing.texi (Parsing Program Source): New chapter.
* lisp/emacs-lisp/cl-preloaded.el (cl--typeof-types): Add
treesit-parser and treesit-node type.
* lisp/treesit.el: New file.
* src/Makefile.in (TREE_SITTER_LIBS, TREE_SITTER_FLAGS,
TREE_SITTER_OBJ): New variables.
* src/alloc.c:
(cleanup_vector): Add cleanup code for treesit-parser and
treesit-node.
* src/casefiddle.c (casify_region): Notify tree-sitter parser of
buffer change.
* src/data.c (Ftype_of): Add treesit-parser and treesit-node type
(Qtreesit_parser, Qtreesit_node): New symbol.
* src/emacs.c (main): Add symbols in treesit.c.
* src/eval.c (define_error): Move the function to here.
* src/insdel.c (insert_1_both, insert_from_string_1, insert_from_gap,
insert_from_buffer_1, replace_range, del_range_2): Notify tree-sitter
parser of buffer change.
* src/json.c (define_error): Move this function out.
* src/lisp.h (DEFINE_GDB_SYMBOL_BEGIN): Add treesit-parser and
treesit-node.
* src/lread.c (Vdynamic_library_suffixes): New variable.
* src/print.c (print_vectorlike): Add code for printing
treesit-parser and treesit-node.
* src/treesit.c: New file.
* src/treesit.h: New file.
* test/src/treesit-tests.el: New file.
2022-05-07 01:11:39 -07:00