guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: guix-commits
Subject: 02/05: read-print: Correctly support multiple same-named newline forms.
Date: Tue, 20 Sep 2022 13:29:08 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 7a698da0d04d75f1c49f9ae9f358070acab0f781
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sat Sep 17 16:15:17 2022 +0200

    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.
---
 guix/read-print.scm  | 7 +++----
 tests/read-print.scm | 5 +++++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/guix/read-print.scm b/guix/read-print.scm
index a5a1b708bf..c8849e767b 100644
--- a/guix/read-print.scm
+++ b/guix/read-print.scm
@@ -367,10 +367,9 @@ surrounding SYMBOL."
 (define (newline-form? symbol context)
   "Return true if parenthesized expressions starting with SYMBOL must be
 followed by a newline."
-  (match (vhash-assq symbol %newline-forms)
-    (#f #f)
-    ((_ . prefix)
-     (prefix? prefix context))))
+  (let ((matches (vhash-foldq* cons '() symbol %newline-forms)))
+    (find (cut prefix? <> context)
+          matches)))
 
 (define (escaped-string str)
   "Return STR with backslashes and double quotes escaped.  Everything else, in
diff --git a/tests/read-print.scm b/tests/read-print.scm
index ca3f3193f7..ea52a52145 100644
--- a/tests/read-print.scm
+++ b/tests/read-print.scm
@@ -294,6 +294,11 @@ mnopqrstuvwxyz.\")"
   ;; page break above
   end)")
 
+(test-pretty-print "\
+(home-environment
+  (services
+   (list (service-type home-bash-service-type))))")
+
 (test-pretty-print/sequence "\
 ;;; This is a top-level comment.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]