From ccd2509ed31f953408240357e9b84c3d3b3f6a2b Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Tue, 1 Nov 2022 00:39:58 -0700 Subject: [PATCH] Don't print buffer when printing tree-sitter node and parser Additionally, print node's position in buffer. * doc/lispref/parsing.texi (Retrieving Node): Reflect this change in manual. * src/print.c (print_vectorlike): Remove printing of buffer, add printing of node position. --- doc/lispref/parsing.texi | 4 ++-- src/print.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 7164baaa6d2..e280ac8c645 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -516,7 +516,7 @@ Example: @group ;; Find the node at point in a C parser's syntax tree. (treesit-node-at (point) 'c) - @result{} # + @result{} # @end group @end example @end defun @@ -617,7 +617,7 @@ This function finds the child of @var{node} whose field name is @group ;; Get the child that has "body" as its field name. (treesit-child-by-field-name node "body") - @result{} # + @result{} # @end group @end example @end defun diff --git a/src/print.c b/src/print.c index 0c50cbab09a..a6cb0191c7f 100644 --- a/src/print.c +++ b/src/print.c @@ -2018,9 +2018,9 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, case PVEC_TS_PARSER: print_c_string ("#language_symbol; + /* No need to print the buffer because it's not that useful: we + usually know which buffer a parser belongs to. */ print_string (Fsymbol_name (language), printcharfun); - print_c_string (" in ", printcharfun); - print_object (XTS_PARSER (obj)->buffer, printcharfun, escapeflag); printchar ('>', printcharfun); break; case PVEC_TS_NODE: @@ -2034,8 +2034,9 @@ print_vectorlike (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag, print_string (Ftreesit_node_type (obj), printcharfun); print_c_string (delim2, printcharfun); print_c_string (" in ", printcharfun); - print_object (XTS_PARSER (XTS_NODE (obj)->parser)->buffer, - printcharfun, escapeflag); + print_object (Ftreesit_node_start (obj), printcharfun, escapeflag); + printchar ('-', printcharfun); + print_object (Ftreesit_node_end (obj), printcharfun, escapeflag); printchar ('>', printcharfun); break; case PVEC_TS_COMPILED_QUERY: -- 2.39.5