emacs-tree-sitter / elisp-tree-sitter

Emacs Lisp bindings for tree-sitter
https://emacs-tree-sitter.github.io
MIT License
816 stars 73 forks source link

Friendlier printed representation #138

Open mickeynp opened 3 years ago

mickeynp commented 3 years ago

Is it possible to replace the printed hash notation of nodes (or trees, I guess) with something more user friendly? I'm thinking #<some_node_type (1 . 5) ptr=...> or something to that effect: basically the node type and position range. That would make debugging and inspecting queries far easier.

Thanks.

ubolonton commented 3 years ago

Dynamic modules cannot currently customize the printed representation of user_ptr objects. Some changes to Emacs's core is necessary to support that.

As a workaround, you can advise the printing and formatting functions: print, prin1, princ, format, format-message, message. I think adding functionalities to tsc to enable/disable such advices should be ok, for debugging purposes.

mickeynp commented 3 years ago

Ah! Advising the printing functions: that's a good idea I had not considered. Thanks for your help.