On 30/6/26 15:18, Arun Isaac wrote:
It is very hard to programmatically edit S-expressions while still
preserving comments and whitespace correctly.
I started out with the assumption that it was simply a matter of
using `read` and `pretty-print`. But, no: `read` discards all comments
and whitespace.

The other day I discovered "read-with-comments" and "pretty-print-with-comments" in guix/read-print.scm, but I have not yet used them myself.

Then, `pretty-print` prints it out in a way that may be
very different from the way the user had originally formatted the file.

I was thinking maybe we should go for a 'canonical' way to format these files? Something like black or clang-format, but for scheme; such a tool does not seem to exist though.

The YAML files you are referring to also have a canonical format.

The reason I discovered those earlier mentioned functions is because I'd like to get `guix style` to the point that we use it on all packages. Because I think that would be the first step to improving the automation of our package maintenance.


Reply via email to