[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/tree-sitter 08a1c32d0b 02/15: Improve printing treesit nodes
From: |
Yuan Fu |
Subject: |
feature/tree-sitter 08a1c32d0b 02/15: Improve printing treesit nodes |
Date: |
Sun, 25 Sep 2022 00:11:59 -0400 (EDT) |
branch: feature/tree-sitter
commit 08a1c32d0bcaa9369a34e7f7d6d01c3885f62e21
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Improve printing treesit nodes
* src/print.c (print_vectorlike): Instead of position, print the type
of the node.
---
src/print.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/print.c b/src/print.c
index 12b5087435..4f41448d86 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2024,12 +2024,15 @@ print_vectorlike (Lisp_Object obj, Lisp_Object
printcharfun, bool escapeflag,
printchar ('>', printcharfun);
break;
case PVEC_TS_NODE:
- print_c_string ("#<treesit-node from ", printcharfun);
- print_object (Ftreesit_node_start (obj),
- printcharfun, escapeflag);
- print_c_string (" to ", printcharfun);
- print_object (Ftreesit_node_end (obj),
- printcharfun, escapeflag);
+ /* Prints #<treesit-node (identifier) in #<buffer xxx>> or
+ #<treesit-node "keyword" in #<buffer xxx>>. */
+ print_c_string ("#<treesit-node ", printcharfun);
+ bool named = ts_node_is_named (XTS_NODE (obj)->node);
+ const char *delim1 = named ? "(" : "\"";
+ const char *delim2 = named ? ")" : "\"";
+ print_c_string (delim1, printcharfun);
+ 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);
- feature/tree-sitter b584569014 05/15: Change make_string to build_string in treesit.c, (continued)
- feature/tree-sitter b584569014 05/15: Change make_string to build_string in treesit.c, Yuan Fu, 2022/09/25
- feature/tree-sitter 17422c2cfc 06/15: ; * src/treesit.c (Ftreesit_node_field_name_for_child): Doc fix., Yuan Fu, 2022/09/25
- feature/tree-sitter eba6582436 09/15: Add the treesit-search functions that supplant the removed ones, Yuan Fu, 2022/09/25
- feature/tree-sitter a31538ea5b 12/15: Fix treesit-search-forward, Yuan Fu, 2022/09/25
- feature/tree-sitter ef6e18a6b9 13/15: Improve treesit-search-forward-goto, Yuan Fu, 2022/09/25
- feature/tree-sitter 9e339415b4 14/15: Fix treesit-induce-sparse-tree, Yuan Fu, 2022/09/25
- feature/tree-sitter c5147882a9 03/15: ; Minor manual fix for tree-sitter indent, Yuan Fu, 2022/09/25
- feature/tree-sitter 914f68da05 04/15: ; Minor tree-sitter manual fix, Yuan Fu, 2022/09/25
- feature/tree-sitter 013c7d6aae 01/15: Rename treesit-expand-query/pattern, Yuan Fu, 2022/09/25
- feature/tree-sitter 9ed53535f5 15/15: ; * lisp/progmodes/python.el (python-mode): Fix typo., Yuan Fu, 2022/09/25
- feature/tree-sitter 08a1c32d0b 02/15: Improve printing treesit nodes,
Yuan Fu <=
- feature/tree-sitter 1575ee2eeb 07/15: Accept nil as NODE in treesit-node-text, Yuan Fu, 2022/09/25
- feature/tree-sitter f071e61d10 10/15: ; Fix docstrings in treesit.el, Yuan Fu, 2022/09/25
- feature/tree-sitter 795e01ac24 11/15: Update and enable treesit-imenu function in python.el, Yuan Fu, 2022/09/25