mbox series

[bug#56898,00/13] Put the pretty printer to good use

Message ID 20220802214236.18965-1-ludo@gnu.org
Headers show
Series Put the pretty printer to good use | expand

Message

Ludovic Courtès Aug. 2, 2022, 9:42 p.m. UTC
Hello Guix!

I shaved a yak!  This patch series promotes the pretty reader/printer
of ‘guix style’ to its own module, improves it so it can deal with
vertical space, adds a ‘-f’ option to ‘guix style’ to reformat
whole files, changes the installer to use this pretty-printer, and
changes the installer so it emits comments and vertical space in
the generated configuration.

You can use ‘guix style -f’ on any Scheme file.  The pretty-printer
does a decent job, though there are still cases where it’s not as
good as my little hands at formatting things nicely.  For newcomers,
it should be very helpful.

Comments?  Vertical space?  Page breaks?

Ludo’.

Ludovic Courtès (13):
  style: Move reader and printer to (guix read-print).
  read-print: Add System and Home special forms.
  read-print: Expose comment constructor.
  read-print: Introduce <blank> parent class of <comment>.
  style: Adjust test to not emit blank lines.
  read-print: Read and render vertical space.
  read-print: Recognize page breaks.
  read-print: Add code to read and write sequences of
    expressions/blanks.
  read-print: 'canonicalize-comment' leaves top-level comments
    unchanged.
  style: Add '--whole-file' option.
  read-print: Support printing multi-line comments.
  installer: Render the final configuration with (guix read-print).
  installer: Add comments and vertical space to the generated config.

 Makefile.am                |   3 +
 doc/guix.texi              |  28 +-
 gnu/installer.scm          |   3 +-
 gnu/installer/parted.scm   |  10 +-
 gnu/installer/services.scm |  39 ++-
 gnu/installer/steps.scm    |  32 +-
 gnu/installer/user.scm     |   7 +-
 guix/read-print.scm        | 678 +++++++++++++++++++++++++++++++++++++
 guix/scripts/import.scm    |   4 +-
 guix/scripts/style.scm     | 527 +++-------------------------
 tests/guix-style.sh        |  80 +++++
 tests/read-print.scm       | 358 ++++++++++++++++++++
 tests/style.scm            | 185 +---------
 13 files changed, 1270 insertions(+), 684 deletions(-)
 create mode 100644 guix/read-print.scm
 create mode 100644 tests/guix-style.sh
 create mode 100644 tests/read-print.scm


base-commit: d7e7494bc4d69de9db49488ee812e572c3250211

Comments

Mathieu Othacehe Aug. 7, 2022, 10:50 a.m. UTC | #1
Hey Ludo,

Wow, nice! I tested the installer part, everything seems to work fine
and the new comments are a welcomed addition.

Thanks,

Mathieu
Ludovic Courtès Aug. 7, 2022, 8:18 p.m. UTC | #2
Hi Mathieu,

Mathieu Othacehe <othacehe@gnu.org> skribis:

> Wow, nice! I tested the installer part, everything seems to work fine
> and the new comments are a welcomed addition.

Thanks for taking a look, I’m glad you liked it!

I guess we could add more comments in the generated OS config to guide
people; I wasn’t sure where to add them and how to frame them, but we
can do that later.

Ludo’.
Ludovic Courtès Aug. 9, 2022, 9:42 a.m. UTC | #3
Ludovic Courtès <ludo@gnu.org> skribis:

>   style: Move reader and printer to (guix read-print).
>   read-print: Add System and Home special forms.
>   read-print: Expose comment constructor.
>   read-print: Introduce <blank> parent class of <comment>.
>   style: Adjust test to not emit blank lines.
>   read-print: Read and render vertical space.
>   read-print: Recognize page breaks.
>   read-print: Add code to read and write sequences of
>     expressions/blanks.
>   read-print: 'canonicalize-comment' leaves top-level comments
>     unchanged.
>   style: Add '--whole-file' option.
>   read-print: Support printing multi-line comments.
>   installer: Render the final configuration with (guix read-print).
>   installer: Add comments and vertical space to the generated config.

Oops, forgot to close: I pushed this series as
ff9522fb69b9f4a31a5b766029e26dc53a2d1cf8 yesterday.

Lemme know how it goes!

Ludo’.