mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 21:59:08 -05:00
style: Keep values next to their keyword.
This ensures we print '#:key value' rather than insert a newline between '#:key' and 'value' as was the case before. * guix/scripts/style.scm (pretty-print-with-comments)[print-sequence]: When ITEM is a keyword, loop with FIRST? = true. * tests/style.scm: Add test.
This commit is contained in:
parent
c9d78e4074
commit
2ccbf3a45c
2 changed files with 14 additions and 1 deletions
|
@ -303,7 +303,8 @@ (define newline?
|
|||
(newline port)
|
||||
(display (make-string indent #\space) port))
|
||||
(let ((column (if newline? indent column)))
|
||||
(print tail #f
|
||||
(print tail
|
||||
(keyword? item) ;keep #:key value next to one another
|
||||
(comment? item)
|
||||
(loop indent column
|
||||
(or newline? delimited?)
|
||||
|
|
|
@ -492,6 +492,18 @@ (define file
|
|||
'(#:phases %standard-phases
|
||||
#:tests? #f)))")
|
||||
|
||||
;; '#:key value' is kept on the same line.
|
||||
(test-pretty-print "\
|
||||
(package
|
||||
(name \"keyword-value-same-line\")
|
||||
(arguments
|
||||
(list #:phases #~(modify-phases %standard-phases
|
||||
(add-before 'x 'y
|
||||
(lambda* (#:key inputs #:allow-other-keys)
|
||||
(foo bar baz))))
|
||||
#:make-flags #~'(\"ANSWER=42\")
|
||||
#:tests? #f)))")
|
||||
|
||||
(test-equal "pretty-print-with-comments, canonicalize-comment"
|
||||
"\
|
||||
(list abc
|
||||
|
|
Loading…
Reference in a new issue