From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id gNzYJD91ZGcNyAAAe85BDQ:P1 (envelope-from ) for ; Thu, 19 Dec 2024 19:34:23 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id gNzYJD91ZGcNyAAAe85BDQ (envelope-from ) for ; Thu, 19 Dec 2024 20:34:23 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=HHQKERV3; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=PQmH35jz; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734636863; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Y3r8MQp/2/d8p8BJAtI4tXPjSqSX89/c314eRijplQs=; b=Y2Eh29OHUtwT6b+QZoGEnUjG4EszKEj/xvnEekJ7WxW8H5QODlh2Q9lXvKFhMUSICoo6zZ idC+WtWGV4tf48anGPYUP+qUZQpIra/cgXM18eiTnUedXNZRfYds0vEjeqZzCStdzDgiiH 2MIq3hJ7Oc+JEH0BFXc3KwdtFLe+MJH4rw1/568tfFmdtaA3OvDvHXXrmgQ7J63NRMiSmk RIhTTaMpehFnhOklAMO1LQVRuMpGh/rhJEmXha5F5OsFwCb8A4ffyDvyAUWDsWtpYWdxVs ADRDXjduN3JLF7JVBD6j3U+E0mTJkFmexSto8maWLEuygQtAVuJdiCB5BeBMzQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=HHQKERV3; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=PQmH35jz; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734636863; a=rsa-sha256; cv=none; b=IdC2pg3qRTIGyGK0rQcnZk4jpyShe6aayCO0XQfAGbPlhd2ZzlWxBzsD218+qOfhsarE9J JWi7CYz9M5boOM0XLIIhnI8+vfIQaKjjHcrtDTXnw5PSHclZCh4YoRn+OMKJLRjIaW2Prj 3W+OOfotXX2OG+Kvhwx/EHLH4DATJpqNwOBQpzVoxYw8LPTslLeIJ0w+n+p1xpBUphSgl5 B5nyWt5uzpYLj0EZp58wNPgmD6iYRzgTwrJgrPD1G/+hLrTz8G3DxwK/s9LTZA4HpDKIZz /YR5gF8TZ4U9/qTvwwXuRMe6lPzWwvLH4kHsIzLegIKcrXWztEE1vYSTMld4xg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5B7CE1AAF5 for ; Thu, 19 Dec 2024 20:34:23 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOMHd-0002Zk-0p; Thu, 19 Dec 2024 14:34:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOMHb-0002YX-DG for guix-patches@gnu.org; Thu, 19 Dec 2024 14:34:03 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOMHb-0002mh-49; Thu, 19 Dec 2024 14:34:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=Y3r8MQp/2/d8p8BJAtI4tXPjSqSX89/c314eRijplQs=; b=HHQKERV3USFYKB4Gc0RrK+q/yTxM16draUBdJGbOs6oQDxK3rLv99+aesfCRdE77QWnJA/61ZUYKdrFZMTtMF2BuqG3PLSuivYqxNcp/Q1g6yyRJX0fBFD0nmblx6Kw6VFHIKZOI8XbGdZD/FzARLPv51Zuacq99v6ysFy9ziH8jeTfQ63sZ60YABGEuFFNxt24l+B8FACd333Qj272e4hoR/2nbBpjYSZ8Z+2nPZh4Mw6hHRLLFNwltqkrrwHb25gOt7qaeHiStXvkAAM3YgR/5oKOTHw4frovhh+paQGDlpCidi6dwVLRf+UQ68qzQ1uSlQECo+u0ce57TYXtp/Q==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tOMHZ-0000T6-OL; Thu, 19 Dec 2024 14:34:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74979] [PATCH 1/4] scripts: style: Refactor order-packages. Resent-From: Herman Rimm Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 19 Dec 2024 19:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74979 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74979@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 74979-submit@debbugs.gnu.org id=B74979.17346368391781 (code B ref 74979); Thu, 19 Dec 2024 19:34:01 +0000 Received: (at 74979) by debbugs.gnu.org; 19 Dec 2024 19:33:59 +0000 Received: from localhost ([127.0.0.1]:40143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOMHX-0000SZ-A3 for submit@debbugs.gnu.org; Thu, 19 Dec 2024 14:33:59 -0500 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117]:34221 helo=email.rimm.ee) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOMHV-0000SA-Dr for 74979@debbugs.gnu.org; Thu, 19 Dec 2024 14:33:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1734636828; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y3r8MQp/2/d8p8BJAtI4tXPjSqSX89/c314eRijplQs=; b=PQmH35jzxuU/WnYf1fxuFwW4zeZ4AEGYOVsNeanOI5AvlXi2hXYy30sqZ6sU01K1IR98m+ fXLuG88xKIYaZSlEii3MSmks3fBETiRjNV7twj8qbgOAIcxlaAUFZb3Ida3bI3bu6fg8qL jfO/LijAgApTu+SYDIG+2R8sQBNuFGceAgRDMZ8inbTlJpCVQ4LpY7Wh1WgAsBTxGzFEMY 771kMT30kIs61dk+RcnfEEcU9UbvvCs3T88s0870GyrufiBGb2oNc0iK4hsIeWTNSoqIC3 RnGL5CMX+BkhbJOiy3ydz426DxwyJ8JTDDCeCijfEFOPaERR5DAfsUqa/aDY4g== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id 6966bcf3 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO) for <74979@debbugs.gnu.org>; Thu, 19 Dec 2024 19:33:48 +0000 (UTC) Date: Thu, 19 Dec 2024 20:33:04 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Herman Rimm X-ACL-Warn: , Herman Rimm via Guix-patches From: Herman Rimm via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -4.72 X-Spam-Score: -4.72 X-Migadu-Queue-Id: 5B7CE1AAF5 X-TUID: 4bYHHh9q6gwS * guix/scripts/style.scm (order-packages): Combine package-name and package-version procedures into package-fields. (format-whole-file): Do not sort copyright headers or module definition. Change-Id: I5507bf8ed221f7017f972f0e0e64d149bea4854b --- guix/scripts/style.scm | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/guix/scripts/style.scm b/guix/scripts/style.scm index 51234952e9..4b704ddfb7 100644 --- a/guix/scripts/style.scm +++ b/guix/scripts/style.scm @@ -43,6 +43,7 @@ (define-module (guix scripts style) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) + #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-37) @@ -500,31 +501,19 @@ (define (order-packages lst) "Return LST, a list of top-level expressions and blanks, with top-level package definitions in alphabetical order. Packages which share a name are placed with versions in descending order." - (define (package-name pkg) + (define (package-fields pkg) (match pkg ((('define-public _ expr) _ ...) (match expr - ((or ('package _ ('name name) _ ...) - ('package ('name name) _ ...)) - name) - (_ #f))) - (_ #f))) - - (define (package-version pkg) - (match pkg - ((('define-public _ expr) _ ...) - (match expr - ((or ('package _ _ ('version version) _ ...) - ('package _ ('version version) _ ...)) - version) - (_ #f))) - (_ #f))) + ((or ('package _ ('name name) ('version version) _ ...) + ('package ('name name) ('version version) _ ...)) + (values name version)) + (_ (values #f #f)))) + (_ (values #f #f)))) (define (package>? lst1 lst2) - (let ((name1 (package-name lst1)) - (name2 (package-name lst2)) - (version1 (package-version lst1)) - (version2 (package-version lst2))) + (let-values (((name1 version1) (package-fields lst1)) + ((name2 version2) (package-fields lst2))) (and name1 name2 (or (string>? name1 name2) (and (string=? name1 name2) version1 @@ -550,7 +539,12 @@ (define* (format-whole-file file order? #:rest rest) (let* ((lst (call-with-input-file file read-with-comments/sequence #:guess-encoding #t)) (lst (if order? - (order-packages lst) + (let loop ((lst lst)) + (match lst + (((? blank? blank) rest ...) + (cons blank (loop rest))) + ((module rest ...) + (cons module (order-packages rest))))) lst))) (with-atomic-file-output file (lambda (port) -- 2.45.2