1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 21:20:33 +02:00

read-print: Recognize page breaks.

* guix/read-print.scm (<page-break>, page-break?, page-break)
(char-set:whitespace-sans-page-break): New variables.
(space?): New procedure.
(read-vertical-space): Use it.
(read-until-end-of-line): New procedure.
(read-with-comments): Add #\page case.
(pretty-print-with-comments): Add 'page-break?' case.
* tests/read-print.scm ("read-with-comments: top-level page break"): New
test.
Add round-trip test with page break within an sexp.
This commit is contained in:
Ludovic Courtès
2022-08-02 15:29:55 +02:00
parent f687e27e03
commit 077324a16f
2 changed files with 65 additions and 3 deletions

View File

@@ -70,6 +70,21 @@
(read-with-comments port)
(read-with-comments port)))))
(test-equal "read-with-comments: top-level page break"
(list (comment ";; Begin.\n") (vertical-space 1)
(page-break)
(comment ";; End.\n"))
(call-with-input-string "\
;; Begin.
;; End.\n"
(lambda (port)
(list (read-with-comments port)
(read-with-comments port)
(read-with-comments port)
(read-with-comments port)))))
(test-pretty-print "(list 1 2 3 4)")
(test-pretty-print "((a . 1) (b . 2))")
(test-pretty-print "(a b c . boom)")
@@ -229,6 +244,13 @@ mnopqrstuvwxyz.\")"
;; Comment after blank line.
two)")
(test-pretty-print "\
(begin
break
;; page break above
end)")
(test-equal "pretty-print-with-comments, canonicalize-comment"
"\
(list abc