emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8facdb62d3e 3/3: Improve docstring for treesit-language-at


From: Yuan Fu
Subject: master 8facdb62d3e 3/3: Improve docstring for treesit-language-at
Date: Wed, 13 Sep 2023 21:15:40 -0400 (EDT)

branch: master
commit 8facdb62d3e7e42a36cbbd164be93e72d1ce2663
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    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.
---
 lisp/treesit.el | 13 +++++++++++--
 1 file 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."
 This is used by `treesit-language-at', which is used by various
 functions to determine which parser to use at point.
 
-The function is called with one argument, the position of point.")
+The function is called with one argument, the position of point.
+
+In general, this function should call `treesit-node-at' with an
+explicit language (usually the host language), and determine the
+language at point using the type of the returned node.")
 
 (defun treesit-language-at (position)
   "Return the language at POSITION.
+
 This function assumes that parser ranges are up-to-date.  It
 returns the return value of `treesit-language-at-point-function'
 if it's non-nil, otherwise it returns the language of the first
-parser in `treesit-parser-list', or nil if there is no parser."
+parser in `treesit-parser-list', or nil if there is no parser.
+
+In a multi-language buffer, make sure
+`treesit-language-at-point-function' is implemented!  Otherwise
+`treesit-language-at' wouldn't return the correct result."
   (if treesit-language-at-point-function
       (funcall treesit-language-at-point-function position)
     (when-let ((parser (car (treesit-parser-list))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]