Subject: [bug#74979] [PATCH 2/4] scripts: style: Sort more kinds of package definitions.

From: Herman Rimm <[email-masked]>
Date: Thu, 19 Dec 2024 20:33:05 +0100

* guix/scripts/style.scm (order-packages): Match comments before package
S-exp. and its fields.  Match in let.  Match package/inherit.

Change-Id: I48a5976930501c20415b5413966b5294958bc23b
---
 guix/scripts/style.scm | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm
index 4b704ddfb7..6f07f6c3b9 100644
--- a/guix/scripts/style.scm
+++ b/guix/scripts/style.scm
@@ -503,13 +503,14 @@ (define (order-packages lst)
 share a name are placed with versions in descending order."
   (define (package-fields pkg)
     (match pkg
-      ((('define-public _ expr) _ ...)
+      ((('define-public pkg _ ... (or ('let _ expr) expr)) _ ...)
        (match expr
-         ((or ('package _ ('name name) ('version version) _ ...)
-              ('package ('name name) ('version version) _ ...))
-          (values name version))
-         (_ (values #f #f))))
-      (_ (values #f #f))))
+         (((or 'package 'package/inherit) fields ...)
+          (let ((name (and=> (assoc-ref fields 'name) first))
+                (version (and=> (assoc-ref fields 'version) first)))
+            (values name version)))
+         (_ (and (values #f #f)))))
+      (_ (and (values #f #f)))))
 
   (define (package>? lst1 lst2)
     (let-values (((name1 version1) (package-fields lst1))
-- 
2.45.2