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.
This commit is contained in:
parent
818220f1cc
commit
7a698da0d0
@ -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
|
||||||
|
@ -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.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user