[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
09/11: style: Keep values next to their keyword.
From: |
guix-commits |
Subject: |
09/11: style: Keep values next to their keyword. |
Date: |
Wed, 22 Jun 2022 17:50:17 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 2ccbf3a45ccb5b1ac469f3d429faf4c51c56f38a
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Jun 22 23:39:50 2022 +0200
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.
---
guix/scripts/style.scm | 3 ++-
tests/style.scm | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm
index 8123570c38..ca3853af5e 100644
--- a/guix/scripts/style.scm
+++ b/guix/scripts/style.scm
@@ -303,7 +303,8 @@ FORMAT-COMMENT is 'canonicalize-comment'."
(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?)
diff --git a/tests/style.scm b/tests/style.scm
index 41f7e31cce..48d975df94 100644
--- a/tests/style.scm
+++ b/tests/style.scm
@@ -492,6 +492,18 @@ mnopqrstuvwxyz.\")"
'(#: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
- branch master updated (4f9ac2afc7 -> 2873433c72), guix-commits, 2022/06/22
- 01/11: services: wireguard: Shepherd 'stop' method really stops., guix-commits, 2022/06/22
- 03/11: gnu: sent: Add farbfeld to propagated-inputs., guix-commits, 2022/06/22
- 02/11: gnu: Add farbfeld., guix-commits, 2022/06/22
- 09/11: style: Keep values next to their keyword.,
guix-commits <=
- 08/11: gnu: libjxl: Update to 0.6.1-0.b7076f18., guix-commits, 2022/06/22
- 10/11: refresh: Repurpose '-L' for '--load-path'., guix-commits, 2022/06/22
- 05/11: gnu: sent: Remove input labels., guix-commits, 2022/06/22
- 04/11: gnu: sent: Apply guix style, guix-commits, 2022/06/22
- 11/11: news: Add entry for 'guix refresh -L' change., guix-commits, 2022/06/22
- 07/11: gnu: google-highway: Update to 0.17.0., guix-commits, 2022/06/22
- 06/11: gnu: reuse: Update to 1.0.0., guix-commits, 2022/06/22