On Fri, May 17 2024, Eli Zaretskii wrote: > As a one-time thing, I don't think anyone will care how the code was > obtained, as long as it is maintained by hand henceforth. > > But if you suggest this as a permanent inclusion into Emacs, then I > don't think we can go that way, since the tools to produce this are > neither standard ones available everywhere, nor something we can > include with Emacs. I think the goal is not to edit the generated code manually but to keep the code generator around and edit that if needed. > Given that Emacs now has tree-sitter bindings, I wonder whether the > same can be done in Emacs Lisp using tree-sitter for parsing. That'd > be acceptable, I think. That's an interesting idea. I tried to rewrite the Python code in Elisp and it works, after a fashion. The tree-sitter syntax tree is at a lower level than what libclang offers and I had to rewrite the tree quite a bit to make it easier to use. I also pipe the C source code through the preprocessor first, so that tree-sitter doesn't see macros. With macros, it's even harder to get some easy to use data structures out of it. I'm not sure how to proceed from here. Anyway the code is here: