]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve printing treesit nodes
authorYuan Fu <casouri@gmail.com>
Sun, 25 Sep 2022 02:19:03 +0000 (19:19 -0700)
committerYuan Fu <casouri@gmail.com>
Sun, 25 Sep 2022 04:11:29 +0000 (21:11 -0700)
* src/print.c (print_vectorlike): Instead of position, print the type
of the node.

src/print.c

index 12b50874359e2e961e38cea9c393a9a97b7bcb3c..4f41448d861dcc745782db55219eb0a240422b67 100644 (file)
@@ -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);