Subject: [bug#70499] [PATCH v2 1/3] guix: Move ‘package-location<?’ to (guix packages).

From: Herman Rimm <[email-masked]>
Date: Sun, 5 May 2024 19:25:33 +0200

* guix/scripts/style.scm (package-location<?): Move to…
* guix/packages.scm (package-location<?): … here.

Change-Id: I8ebb37c261a1bb3fa5772177b27fd62a2553e318
---
 guix/packages.scm      | 11 +++++++++++
 guix/scripts/style.scm |  9 ---------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index 4385e4f930..d878cc071e 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -116,6 +116,8 @@ (define-module (guix packages)
             deprecated-package
             package-field-location
 
+            package-location<?
+
             this-package-input
             this-package-native-input
 
@@ -815,6 +817,15 @@ (define (package-field-location package field)
         #f)))
     (_ #f)))
 
+(define (package-location<? p1 p2)
+  "Return true if P1's location is \"before\" P2's."
+  (let ((loc1 (package-location p1))
+        (loc2 (package-location p2)))
+    (and loc1 loc2
+         (if (string=? (location-file loc1) (location-file loc2))
+             (< (location-line loc1) (location-line loc2))
+             (string<? (location-file loc1) (location-file loc2))))))
+
 (define-syntax-rule (this-package-input name)
   "Return the input NAME of the package being defined--i.e., an input
 from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm
index 211980dc1c..534034b271 100644
--- a/guix/scripts/style.scm
+++ b/guix/scripts/style.scm
@@ -480,15 +480,6 @@ (define* (format-package-definition package
                         #:format-comment canonicalize-comment
                         #:format-vertical-space canonicalize-vertical-space)))))
 
-(define (package-location<? p1 p2)
-  "Return true if P1's location is \"before\" P2's."
-  (let ((loc1 (package-location p1))
-        (loc2 (package-location p2)))
-    (and loc1 loc2
-         (if (string=? (location-file loc1) (location-file loc2))
-             (< (location-line loc1) (location-line loc2))
-             (string<? (location-file loc1) (location-file loc2))))))
-
 
 ;;;
 ;;; Whole-file formatting.
-- 
2.41.0