me
/
guix
Archived
1
0
Fork 0

read-print: Correctly support multiple same-named newline forms.

Previously (home-environment (services ...)) would not be considered a
"newline form".  This fixes it.

* guix/read-print.scm (newline-form?): Use 'vhash-foldq*' instead of
'vhash-assq' and iterate over candidates.
* tests/read-print.scm: Add test.
master
Ludovic Courtès 2022-09-17 16:15:17 +02:00
parent 818220f1cc
commit 7a698da0d0
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 8 additions and 4 deletions

View File

@ -367,10 +367,9 @@ surrounding SYMBOL."
(define (newline-form? symbol context) (define (newline-form? symbol context)
"Return true if parenthesized expressions starting with SYMBOL must be "Return true if parenthesized expressions starting with SYMBOL must be
followed by a newline." followed by a newline."
(match (vhash-assq symbol %newline-forms) (let ((matches (vhash-foldq* cons '() symbol %newline-forms)))
(#f #f) (find (cut prefix? <> context)
((_ . prefix) matches)))
(prefix? prefix context))))
(define (escaped-string str) (define (escaped-string str)
"Return STR with backslashes and double quotes escaped. Everything else, in "Return STR with backslashes and double quotes escaped. Everything else, in

View File

@ -294,6 +294,11 @@ mnopqrstuvwxyz.\")"
;; page break above ;; page break above
end)") end)")
(test-pretty-print "\
(home-environment
(services
(list (service-type home-bash-service-type))))")
(test-pretty-print/sequence "\ (test-pretty-print/sequence "\
;;; This is a top-level comment. ;;; This is a top-level comment.