diff options
| author | Yuan Fu | 2023-09-13 18:14:03 -0700 |
|---|---|---|
| committer | Yuan Fu | 2023-09-13 18:15:28 -0700 |
| commit | 8facdb62d3e7e42a36cbbd164be93e72d1ce2663 (patch) | |
| tree | 4e1bb0dd6e949788f998b865b545374478fa7771 | |
| parent | c916f471caada4eb9a4b7f9f53925a71525c694a (diff) | |
| download | emacs-8facdb62d3e7e42a36cbbd164be93e72d1ce2663.tar.gz emacs-8facdb62d3e7e42a36cbbd164be93e72d1ce2663.zip | |
Improve docstring for treesit-language-at
* lisp/treesit.el (treesit-language-at-point-function)
(treesit-language-at): Several people has confused over this, make it
extra clear than treesit-language-at requires
treesit-language-at-point-function to work.
| -rw-r--r-- | lisp/treesit.el | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el index f65e2e02a7c..520fff04f80 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el | |||
| @@ -136,14 +136,23 @@ Return the root node of the syntax tree." | |||
| 136 | This is used by `treesit-language-at', which is used by various | 136 | This is used by `treesit-language-at', which is used by various |
| 137 | functions to determine which parser to use at point. | 137 | functions to determine which parser to use at point. |
| 138 | 138 | ||
| 139 | The function is called with one argument, the position of point.") | 139 | The function is called with one argument, the position of point. |
| 140 | |||
| 141 | In general, this function should call `treesit-node-at' with an | ||
| 142 | explicit language (usually the host language), and determine the | ||
| 143 | language at point using the type of the returned node.") | ||
| 140 | 144 | ||
| 141 | (defun treesit-language-at (position) | 145 | (defun treesit-language-at (position) |
| 142 | "Return the language at POSITION. | 146 | "Return the language at POSITION. |
| 147 | |||
| 143 | This function assumes that parser ranges are up-to-date. It | 148 | This function assumes that parser ranges are up-to-date. It |
| 144 | returns the return value of `treesit-language-at-point-function' | 149 | returns the return value of `treesit-language-at-point-function' |
| 145 | if it's non-nil, otherwise it returns the language of the first | 150 | if it's non-nil, otherwise it returns the language of the first |
| 146 | parser in `treesit-parser-list', or nil if there is no parser." | 151 | parser in `treesit-parser-list', or nil if there is no parser. |
| 152 | |||
| 153 | In a multi-language buffer, make sure | ||
| 154 | `treesit-language-at-point-function' is implemented! Otherwise | ||
| 155 | `treesit-language-at' wouldn't return the correct result." | ||
| 147 | (if treesit-language-at-point-function | 156 | (if treesit-language-at-point-function |
| 148 | (funcall treesit-language-at-point-function position) | 157 | (funcall treesit-language-at-point-function position) |
| 149 | (when-let ((parser (car (treesit-parser-list)))) | 158 | (when-let ((parser (car (treesit-parser-list)))) |