aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Fu2023-09-13 18:14:03 -0700
committerYuan Fu2023-09-13 18:15:28 -0700
commit8facdb62d3e7e42a36cbbd164be93e72d1ce2663 (patch)
tree4e1bb0dd6e949788f998b865b545374478fa7771
parentc916f471caada4eb9a4b7f9f53925a71525c694a (diff)
downloademacs-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.el13
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."
136This is used by `treesit-language-at', which is used by various 136This is used by `treesit-language-at', which is used by various
137functions to determine which parser to use at point. 137functions to determine which parser to use at point.
138 138
139The function is called with one argument, the position of point.") 139The function is called with one argument, the position of point.
140
141In general, this function should call `treesit-node-at' with an
142explicit language (usually the host language), and determine the
143language 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
143This function assumes that parser ranges are up-to-date. It 148This function assumes that parser ranges are up-to-date. It
144returns the return value of `treesit-language-at-point-function' 149returns the return value of `treesit-language-at-point-function'
145if it's non-nil, otherwise it returns the language of the first 150if it's non-nil, otherwise it returns the language of the first
146parser in `treesit-parser-list', or nil if there is no parser." 151parser in `treesit-parser-list', or nil if there is no parser.
152
153In 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))))