summaryrefslogtreecommitdiff
path: root/doc/lispref/parsing.texi
Commit message (Collapse)AuthorAgeFilesLines
* ; * doc/lispref/parsing.texi (Parsing Program Source): Improve indexing.Eli Zaretskii2024-05-171-0/+1
|
* * doc/lispref/parsing.texi (Retrieving Nodes): Improve documentation.Juri Linkov2024-02-041-11/+14
| | | | | Update optional arguments 'predicate' and 'include-node' of 'treesit-node-top-level'.
* ; Add 2024 to copyright yearsPo Lu2024-01-021-1/+1
|
* Revert "Fix treesit-node-field-name and friends (bug#66674)"Yuan Fu2023-12-291-2/+2
| | | | | | | | | This reverts commit 9874561f39e62c1c9fada6c2e013f93d9ea65729. See bug#67990. Basically our original code is correct, the error is in libtree-sitter, which only manifests in certain cases. https://github.com/tree-sitter/tree-sitter/pull/2104
* Fix treesit-node-field-name and friends (bug#66674)Yuan Fu2023-12-101-2/+2
| | | | | | | | | | | | | | | So turns out ts_node_field_name_for_child takes a named node index, but we were passing it normal index that counts both named and anonymous nodes. That's what makes the field name all wrong in treesit explorer. * doc/lispref/parsing.texi: (Accessing Node Information): Update docstring. * lisp/treesit.el (treesit-node-index): Add some unrelated comment. (treesit-node-field-name): Get named node index rather than all node index. * src/treesit.c (Ftreesit_node_field_name_for_child): Update docstring, use ts_node_named_child_count.
* ; Fix tree-sitter C binding typos in Elisp manual.Basil L. Contovounesios2023-06-301-3/+3
|
* Describe primarily the Emacs s-exp dialect for treesit queriesMattias EngdegÄrd2023-06-181-66/+66
| | | | | | | | * doc/lispref/parsing.texi (Pattern Matching, Multiple Languages): Writing tree-sitter queries as Emacs s-expressions is much more convenient than using the native query notation inside a string, so it makes sense to base the documentation on the former dialect (bug#64017).
* Improve tree-sitter docsBasil L. Contovounesios2023-06-131-153/+142
| | | | | | | | | | | | | | | | | | | | | | | * doc/lispref/positions.texi (List Motion): Incorporate more accurate description of treesit-defun-type-regexp from '(elisp) Tree-sitter Major Modes', replacing that duplicate entry (bug#64018). * doc/lispref/parsing.texi (Parsing Program Source) (Language Grammar, Using Parser, Retrieving Nodes) (Accessing Node Information, Pattern Matching, Multiple Languages): (Tree-sitter Major Modes): * doc/lispref/modes.texi (Parser-based Font Lock): Improve wording, grammar, punctuation, and markup. Fix typos. (Parser-based Indentation): Ditto. Document indent rule presets field-is, catch-all, nth-sibling, grand-parent, and great-grand-parent. * lisp/treesit.el (treesit-simple-indent-presets): Mention field-is, catch-all, nth-sibling, grand-parent, great-grand-parent in docstring. (treesit-major-mode-setup, treesit-explore-mode): Improve docstring/commentary grammar.
* Fix some Texinfo markup in manualsBasil L. Contovounesios2023-06-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/emacs/macos.texi (Mac / GNUstep Customization): * doc/lispintro/emacs-lisp-intro.texi (condition-case): * doc/lispref/control.texi (pcase Macro): * doc/lispref/debugging.texi (Internals of Debugger): * doc/lispref/internals.texi (Building Emacs): * doc/lispref/modes.texi (Imenu): (Parser-based Font Lock, Parser-based Indentation): * doc/lispref/parsing.texi (Retrieving Nodes, Tree-sitter C API): * doc/lispref/processes.texi (Network, Bindat Types): * doc/lispref/searching.texi (Rx Functions): * doc/lispref/text.texi (Replacing): * doc/lispref/windows.texi (Textual Scrolling): * doc/misc/calc.texi (Killing From Stack, Customizing Calc): * doc/misc/cc-mode.texi (Misc Font Locking, List Line-Up): * doc/misc/ede.texi (ede-cpp-root-project) (ede-proj-target-makefile, ede-sourcecode): * doc/misc/ert.texi (Running Tests in Batch Mode): * doc/misc/eudc.texi (Emacs-only Configuration, The Server Hotlist): * doc/misc/eww.texi (Advanced): * doc/misc/flymake.texi (Starting Flymake) (Proc customization variables): * doc/misc/tramp.texi (File name completion): * doc/misc/gnus.texi (Summary Buffer Lines, Gnus Registry Setup) (Fancy splitting to parent, Customizing the IMAP Connection) (Mail Source Specifiers, Agent as Cache): Consistently mark up nil and t as @code. Also fix the markup and wording of some surrounding text (bug#64016). * doc/lispref/display.texi (SVG Images, Icons): * doc/lispref/modes.texi (Customizing Keywords): Prefer ASCII apostrophe over Unicode right single quotation mark.
* ; Fix markup of some treesit vars in Elisp manual.Basil L. Contovounesios2023-05-221-3/+3
| | | | | | | * doc/lispref/modes.texi (Parser-based Font Lock): (Parser-based Indentation): * doc/lispref/parsing.texi (Multiple Languages): Use @code in place of @var when the argument is not a metavariable.
* Improve docstring of treesit-parent-while (bug#62301)Yuan Fu2023-03-211-8/+14
| | | | | | * doc/lispref/parsing.texi (Retrieving Nodes): Improve and fix docstring for treesit-parent-until and treesit-parent-while. * lisp/treesit.el (treesit-parent-while): Improve docstring.
* ; Fix recent changes in treesit docsEli Zaretskii2023-02-101-6/+6
| | | | | * doc/lispref/parsing.texi (Accessing Node Information): Fix wording and indexing, and add cross-reference.
* Rename LIMIT to DEPTH in tree-sitter functions (bug#61231)Yuan Fu2023-02-091-6/+6
| | | | | | | | | I only changed the Lisp functions, internal functions are left unchanged. * doc/lispref/parsing.texi (Retrieving Nodes): Update manual. * src/treesit.c (Ftreesit_search_subtree) (Ftreesit_induce_sparse_tree): Change LIMIT to DEPTH.
* ; Fix incorrect function name in treesit manualSimon Pugnet2023-02-091-3/+3
| | | | | | | | | | | | An example in the documentation uses the function 'treesit-get-parser-create' which does not exist. Replace this with 'treesit-parser-create'. * admin/notes/tree-sitter/html-manual/Multiple-Languages.html: * doc/lispref/parsing.texi (Multiple Languages): Change example. Copyright-paperwork-exempt: yes
* Add 'live' property to treesit-node-check (bug#61235)Yuan Fu2023-02-091-1/+6
| | | | | | | * doc/lispref/parsing.texi (Accessing Node Information): Document. * src/treesit.c (treesit_parser_live_p): New function. (Ftreesit_node_check): Add 'live' property. * test/src/treesit-tests.el (treesit-node-api): Add tests.
* ; Update tree-sitter major mode manualYuan Fu2023-01-191-16/+35
| | | | * doc/lispref/parsing.texi (Tree-sitter Major Modes): Update.
* ; Improve documentation of tree-sitter node comparisonEli Zaretskii2023-01-131-2/+6
| | | | | | * doc/lispref/parsing.texi (Accessing Node Information): * src/treesit.c (Ftreesit_node_eq): Improve documentation of node comparison.
* Equal now recognizes tree-sitter nodes (bug#60659)Yuan Fu2023-01-121-1/+1
| | | | | | | | | | | Now equal uses ts_node_eq to check equality between nodes. * doc/lispref/parsing.texi: (Accessing Node Information): Update manual. * src/fns.c (internal_equal): Handle tree-sitter nodes. * src/treesit.c (treesit_node_eq): New function. (Ftreesit_node_eq): Factor out. Update docstring. * src/treesit.h (treesit_node_eq): Declare new function.
* ; Minor rewording of tree-sitter terminologyEli Zaretskii2023-01-071-5/+9
| | | | | * doc/lispref/parsing.texi (Retrieving Nodes): Minor rewording. (Bug#60555)
* Tree-sitter doc fixes (bug#60524)Juri Linkov2023-01-041-17/+16
| | | | | | | | | | | | | | | | * doc/lispref/modes.texi (Parser-based Font Lock): Replace :lang with :language. * doc/lispref/parsing.texi (Language Grammar): Replace treesit-load-suffixes with dynamic-library-suffixes. (Retrieving Nodes): Fix function names. (Tree-sitter Major Modes): Fix treesit-ready-p args. Fix pxref to Parser-based Indentation. (Tree-sitter C API): Fix function names. * lisp/treesit.el (treesit--simple-indent-eval): Remove cond BODY duplicated from CONDITION. (treesit)<define-short-documentation-group>: Fix function names.
* ; Fix tree-sitter manual title caseYuan Fu2023-01-021-2/+2
| | | | | | * doc/lispref/elisp.texi: * doc/lispref/modes.texi: * doc/lispref/parsing.texi: Change to title case.
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-011-1/+1
|
* ; Fix recent treesit-related changesEli Zaretskii2022-12-311-3/+3
| | | | | | | | | | | | * lisp/treesit.el (treesit-language-source-alist) (treesit--install-language-grammar-1): Doc fixes. * src/treesit.c (Ftreesit_language_abi_version): Fix a typo in function's Lisp name. Doc fix. (Ftreesit_language_available_p): Fix a typo in the function's C name. * doc/lispref/parsing.texi (Language Grammar): Fix wording.
* Add treesit-language-abi-versionYuan Fu2022-12-301-1/+7
| | | | | | | | | Also rename treesit-language-version to treesit-library-abi-version, because the old name is somewhat misleading. * doc/lispref/parsing.texi (Language Grammar): Update. * src/treesit.c (Ftreesit_library_abi_version): Rename. (Ftreesit_language_abi_version): New function.
* Change "language definition" to "language grammar" in manual.Yuan Fu2022-12-301-31/+31
| | | | | | | | | | | | | | "Language grammar" is apparently the more widely used term among people talking about tree-sitter. To avoid confusion, I think it's good to use that rather than "language definition", which is a term that I made up :-) Feel free to revert this if it is too much change. * doc/lispref/elisp.texi: * doc/lispref/modes.texi: * doc/lispref/parsing.texi: * lisp/treesit.el: Change "language definition" to "language grammar".
* ; * doc/lispref/parsing.texi (Accessing Node Information): Fix typo.Yuan Fu2022-12-301-1/+1
|
* ; * doc/lispref/parsing.texi (Using Parser): Minor improvement.Yuan Fu2022-12-281-1/+3
|
* Fix tree-sitter typosYuan Fu2022-12-281-1/+0
| | | | | | | * doc/lispref/parsing.texi (Tree-sitter major modes): * lisp/progmodes/java-ts-mode.el: * test/src/treesit-tests.el (treesit-defun-navigation-nested-4): Fix typo.
* Add tree-sitter helper functions for ImenuYuan Fu2022-12-271-0/+5
| | | | | | | | | | | | | | | | | | | We didn't add an integration for Imenu because we aren't sure what should it look like. Now we have a pretty good idea. All the major modes copy-paste the two Imenu functions and tweaks them in a standard way. With the addition of treesit-defun-type-regexp and treesit-defun-name-function, now is a good time to standardize Imenu integration. In the next commit we update all the major modes to use this integration. * doc/lispref/modes.texi (Imenu): Add manual. * doc/lispref/parsing.texi (Tree-sitter major modes): Update manual. * lisp/treesit.el (treesit-simple-imenu-settings): New varaible. (treesit--simple-imenu-1) (treesit-simple-imenu): New functions. (treesit-major-mode-setup): Setup Imenu.
* Add a new tree-sitter query predicate 'pred'Yuan Fu2022-12-261-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I realized that using an arbitrary function as the predicate in queries is very helpful for some queries I'm writing for python and javascript, and presumably most other languages[1]. Granted, we can already filter out unwanted nodes by using a function instead of a face for the capture name, and (1) determine whether the captured node is valid and (2) fontify that node if it's valid. However, such approach is a bit more cumbersome and more importantly gets in the way of another potential use of the fontification queries: context extraction. For example, I could use the query for the 'variable' feature to get all the variables in a certain region. In this use-case, we want the filtering happen before returning the captured nodes. Besides, the change is relatively small and straightforward: most code are already there, I just need to add some boilerplate. [1] For a code like aa.bb(cc), we want bb to be in function face, because obviously its a function. But for aa.bb, we want bb to be in property face, because it's a property. In the AST, bb is always a property, the difference between the two cases is the enclosing node: in the first case, aa.bb is in a "call_expression" node, indicating that bb is used as a function (a method). So we want a predicate function that checks whether bb is used as a function or a property, and determine whether it should be in function or property face. * doc/lispref/parsing.texi (Pattern Matching): Update manual. * src/treesit.c (Ftreesit_pattern_expand): Handle :pred. (treesit_predicate_capture_name_to_node): A new function extracted from treesit_predicate_capture_name_to_text. (treesit_predicate_capture_name_to_text): Use the newly extracted function. (treesit_predicate_pred): New predicate function. (treesit_eval_predicates): Add new predicate. Also fix a bug: we want to AND the results of each predicate. * test/src/treesit-tests.el (treesit--ert-pred-last-sibling): New helper function. (treesit-query-api): Test #pred predicate.
* ; Fix vindexes in parsing.texiYuan Fu2022-12-261-7/+15
| | | | | | | | * doc/lispref/parsing.texi (Tree-sitter major modes): Replace vindex with cross-reference to modes.texi. Add manual entry for treesit-defun-type-regexp. * lisp/treesit.el (treesit-defun-type-regexp): Use pred in docstring since we use pred everywhere else.
* ; * doc/lispref/parsing.texi (Retrieving Nodes): Add notice.Yuan Fu2022-12-261-0/+4
|
* ; * doc/lispref/parsing.texi (Using Parser): Remove deleted function.Yuan Fu2022-12-261-6/+0
|
* ; * doc/lispref/parsing.texi (Tree-sitter major modes): Fix @cindex.Eli Zaretskii2022-12-251-3/+3
|
* ; * doc/lispref/parsing.texi: Add a reminder.Yuan Fu2022-12-251-0/+2
|
* ; Fix recent changes in treesit documentationEli Zaretskii2022-12-251-13/+20
| | | | | | | | | * lisp/treesit.el (treesit-defun-name-function, treesit-node-at) (treesit-node-on): Doc fixes. * doc/lispref/parsing.texi (Tree-sitter major modes): Fix wording, punctuation, and indexing. (Retrieving Nodes): Fix wording and add cross-references.
* Add treesit-defun-name and friendsYuan Fu2022-12-241-0/+38
| | | | | | | | | | | | | | | | | | | | 1. We now have treesit-defun-name, powered by treesit-defun-name-function. 2. We now have treesit-add-log-current-defun, which powers add-log-current-defun. 3. c-ts-mode updates its code to take advantage of these new features. 4. Manual updates. * doc/lispref/parsing.texi (Tree-sitter major modes): Add manual for new functions. * lisp/progmodes/c-ts-mode.el (c-ts-mode--defun-name): New function. (c-ts-mode--imenu-1): Extract out into c-ts-mode--defun-name. (c-ts-base-mode): Setup treesit-defun-name-function. * lisp/treesit.el (treesit-defun-name-function) (treesit-add-log-defun-delimiter): New variables. (treesit-defun-at-point) (treesit-defun-name): New functions. (treesit-major-mode-setup): Setup add-log-current-defun-function.
* Make treesit-node-at/on guess language at pointYuan Fu2022-12-241-15/+17
| | | | | | | | | | | If PARSER-OR-LANG is nil, it makes more sense to guess the language at point by treesit-language-at than to simply use the first parser in the parser list. * doc/lispref/parsing.texi (Retrieving Nodes): Update manual. * lisp/treesit.el (treesit-node-at) (treesit-node-on): Guess language at point. Update docstring. (treesit-buffer-root-node): Update docstring.
* Remove comment-start-skip preset in tree-sitter indentation engineYuan Fu2022-12-181-14/+0
| | | | | | | | | | | | | | | Comment indentation should use a adaptive-fill-based indent, rather than comment-start-skip. Also remove manual description of removed variables in treesit.el and add documentation for n-p-gp upon request. * doc/lispref/modes.texi (Parser-based Indentation) * lisp/treesit.el (treesit-simple-indent-presets): Add n-p-gp, remove treesit-comment-start/end, remove comment-start-skip. * doc/lispref/parsing.texi (Tree-sitter major modes): Remove treesit-comment-start/end.
* Make indirect buffers use tree-sitter parsers of their base bufferYuan Fu2022-12-091-1/+9
| | | | | | | | | | | | Fix the problem described in bug#59693. * src/treesit.c (treesit_record_change): Always use the base buffer. (Ftreesit_parser_create): Always use the base buffer. Also change the for loop into FOR_EACH_TAIL (stylistic change). (Ftreesit_parser_list): Always use the base buffer. * doc/lispref/parsing.texi (Using Parser): Update manual. * test/src/treesit-tests.el (treesit-indirect-buffer): New test.
* Add default limit for tree-sitter recursive tree-traversing functionYuan Fu2022-11-261-8/+10
| | | | | | | | | | | This fixes bug#59426. * src/treesit.c (treesit_search_dfs) (treesit_build_sparse_tree): Remove no_limit parameter. (Ftreesit_search_forward, Ftreesit_induce_sparse_tree): Use default limit of 1000. * doc/lispref/parsing.texi (Retrieving Nodes): Update manual.
* ; Fix typosStefan Kangas2022-11-221-1/+1
|
* ; Improve recently-modified documentationEli Zaretskii2022-11-201-1/+1
| | | | | | | | | | | | * lisp/progmodes/python.el (python-base-mode) (python--treesit-fontify-string): * lisp/textmodes/css-mode.el (css-base-mode): * lisp/treesit.el (treesit-ready-p, treesit-comment-end) (treesit-simple-indent-presets): Fix typos and wording in doc strings. * doc/lispref/parsing.texi (Tree-sitter major modes): * doc/lispref/modes.texi (Parser-based Indentation): Fix wording and add cross-references.
* Remove treesit-settingsYuan Fu2022-11-191-14/+8
| | | | | | | | | | Remove it since we are using separate major modes for tree-sitter and native variant now. * doc/lispref/parsing.texi (Tree-sitter major modes): Update manual. * lisp/treesit.el (treesit-settings): Remove option. (treesit--setting-for-mode): Remove function. (treesit-ready-p): Don't check for user preference in treesit-settings.
* Fix tree-sitter comment indentation for C-like languagesYuan Fu2022-11-191-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to indent like this: /* comment comment --> This line aligns with the beginning of the first line */ --> This line aligns with the opening comment token * lisp/treesit.el (treesit-comment-start) (treesit-comment-end): New variables. (treesit-simple-indent-presets): New preset comment-end, comment-start, comment-start-skip * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles) (c-ts-mode) * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules) (java-ts-mode) * lisp/progmodes/js.el (js--treesit-indent-rules) (js-ts-mode) * lisp/progmodes/ts-mode.el (ts-mode--indent-rules) (ts-mode): Add identical indent rules to each mode, and set identical treesit-comment-start/end's. * doc/lispref/modes.texi (Parser-based Indentation) * doc/lispref/parsing.texi (Tree-sitter major modes): Update manual.
* Fix documentation of recent treesit changesEli Zaretskii2022-11-171-36/+40
| | | | | | | | | | * src/treesit.c (Ftreesit_parser_notifiers) (Ftreesit_parser_add_notifier, Ftreesit_parser_remove_notifier): Doc string fixes. * doc/lispref/parsing.texi (Accessing Node Information): Fix wording and punctuation. (Using Parser): Improve indexing and wording.
* Allow checking for outdated nodes in tree-sitterYuan Fu2022-11-161-3/+10
| | | | | | | | | Now you can run (treesit-node-check node 'outdated). * doc/lispref/parsing.texi (Accessing Node Information): Update manual. * src/treesit.c (Ftreesit_node_check): Add new property 'outdated'. * test/src/treesit-tests.el (treesit-node-check): Add tests.
* ; Add documentation for tree-sitter parser after-change notifiersYuan Fu2022-11-161-0/+39
| | | | | | * doc/lispref/parsing.texi (Using Parser): Update manual. * lisp/treesit.el (treesit): Add shordocs. * src/treesit.c: Augment docstrings.
* Add treesit-explore-modeYuan Fu2022-11-161-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | This mode is basically the tree-sitter playground[1] in Emacs: displays the syntax tree with the source side-by-side, kept in sync in real-time. [1] https://tree-sitter.github.io/tree-sitter/playground * doc/lispref/parsing.texi (Language Definitions): Mention in manual. * lisp/treesit.el (treesit--explorer-buffer) (treesit--explorer-source-buffer) (treesit--explorer-language) (treesit--explorer-refresh-timer) (treesit--explorer-highlight-overlay) (treesit--explorer-last-node): New variables. * lisp/treesit.el (treesit--explorer--nodes-to-highlight) (treesit--explorer-refresh) (treesit--explorer-post-command) (treesit--explorer-jump) (treesit--explorer-highlight-node) (treesit--explorer-draw-node): New functions. (treesit--explorer-tree-mode) (treesit-explore-mode): New modes.
* Remove feature that checks whether tree-sitter node "has changes"Yuan Fu2022-11-141-8/+3
| | | | | | | | | | | | | | First of all, we signal error on using an outdated node, so if a node has changes, calling treesit-node-check would only raise an error. Besides, in order to properly answer whether a node has changed, we would have to update the node as the buffer is edited, which we don't do right now. * doc/lispref/parsing.texi (Accessing Node Information): Remove relevant manual text. * src/treesit.c (Ftreesit_node_check): Remove docstring mentions, remove the branch for "has-changes". (syms_of_treesit): Remove has-changes.