From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id aIL1BvH8w2VcgAEA62LTzQ:P1 (envelope-from ) for ; Wed, 07 Feb 2024 22:58:09 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id aIL1BvH8w2VcgAEA62LTzQ (envelope-from ) for ; Wed, 07 Feb 2024 22:58:09 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b="aB/W95Qr"; 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=1707343089; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=0rK3aN9asCsaUq+Cn675IoolNO2vaB0oi9Y081BVDho=; b=J+X9aAqViEeluiwK06SGSGDs8awFClw0EcjJ0QDa6AnT84t3DMq6LGivJxsjTBEJYQlme6 bpxLkBSbk6nbjqAMvHDR9Yhu/FuaDzXs/1a7vlAC5pbimdsQUhzwzZ4hWf6DtmT7PadHEX JPi93d8oyVsVH+z5JhsbRZ+l0yvqBSmNrRs4lazfXYJMCvwOH8yDJMMYuUsKaSG8ZaTWsS 1f1LidjyChlugtN8AsKFjxZ5sdRAQFV3a3m9Uu5TmbTaB8KbWmeghnmRIAQP3A0qBiZE0h 2TmitWjfMI9u6LrZjSOTGvvb9w804Z4P0r1Puho33+N6hgTKtGg4OChRrJiq5Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b="aB/W95Qr"; 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=1707343089; a=rsa-sha256; cv=none; b=nAF5pC8iG5IhmvngpRPF9ozK9/ehbSUA4Y9eFaTIgpMDXmEdk6SPNhFi6/fE+8J9ZjcxBO QPinyNU4PnNe7Vj3mvnG4nPnkJrsYgiNPat9DwIQHeL2/ReeItpm3Gn6ah4cGjr9gvLBH/ R+rXq1YxeCrlEwzl5pa9x2BnaR0JtBowhmmO0JoK6ngqqUZLUDXS9dLOaF4scc6zHqWt95 G1IKEoRXsDLEZiJukviqTyY/6tvovWN55TyAS6J/p0uM0JVMO5s6hLJ4MxU6Cq0LzCKtE+ DDQ+SrWCB7vh8YeOKX92XoAKxOu4qrNB7jGYgyy7GTPHjU6QkQ1wJHilErMJnw== 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 E1CA13848B for ; Wed, 7 Feb 2024 22:58:08 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXpvR-0003D9-Nb; Wed, 07 Feb 2024 16:57:49 -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 1rXpvQ-0002y4-EU for guix-patches@gnu.org; Wed, 07 Feb 2024 16:57:48 -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 1rXpvQ-0007rt-5d for guix-patches@gnu.org; Wed, 07 Feb 2024 16:57:48 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rXpve-0002wR-4K for guix-patches@gnu.org; Wed, 07 Feb 2024 16:58:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68935] [PATCH 3/3] guix: import: Put packages into modules in alphabetical order. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 07 Feb 2024 21:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68935 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Herman Rimm Cc: Josselin Poiret , Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , Ricardo Wurmus , 68935@debbugs.gnu.org, Christopher Baines Received: via spool by 68935-submit@debbugs.gnu.org id=B68935.170734306411283 (code B ref 68935); Wed, 07 Feb 2024 21:58:02 +0000 Received: (at 68935) by debbugs.gnu.org; 7 Feb 2024 21:57:44 +0000 Received: from localhost ([127.0.0.1]:58089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXpvL-0002vu-CY for submit@debbugs.gnu.org; Wed, 07 Feb 2024 16:57:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXpvJ-0002ve-4d for 68935@debbugs.gnu.org; Wed, 07 Feb 2024 16:57:42 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXpuw-0007jb-Oj; Wed, 07 Feb 2024 16:57:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=0rK3aN9asCsaUq+Cn675IoolNO2vaB0oi9Y081BVDho=; b=aB/W95QrJGDW2EzXGZkq uvtp+defpwKLpZXzOJMvcVSTuVr2BYP7JuSLMmn1vEqT+REnkFF7M9u0xwyFNhjWSE58Jt0B8X7+i j6PPkI/cLwuHxjY3u6y8Oc5qpkH7Qkth23nnhgRpBAuaQdXfaH9nspa9wCogr2eD/IILNRob0dpsL DVH2v1qzV+NJD7WDOpbIumAkJ9VKMNuWNAvVU/VnC16h4+OhWJ/ebma2U4JCxEPkUpvdVB2Z7HUks S9WxRmAqUqjpFftOxsGBkkcu14P3vqhxQx9VDdjsH3e9GiwXDGr/3jUgJKiyEWDBlqTo0lLx7GSHQ MtV5cXxQg9Zkxw==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: (Herman Rimm's message of "Mon, 5 Feb 2024 16:07:14 +0100") References: X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Nonidi 19 =?UTF-8?Q?Pluvi=C3=B4se?= an 232 de la =?UTF-8?Q?R=C3=A9volution,?= jour de la Pulmonaire X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 07 Feb 2024 22:57:12 +0100 Message-ID: <874jek3pl3.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: , 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-Spam-Score: -5.87 X-Migadu-Scanner: mx13.migadu.com X-Spam-Score: -5.87 X-Migadu-Queue-Id: E1CA13848B X-TUID: i1VmeLg11ovd Herman Rimm skribis: > * guix/scripts/import.scm (guix-import): Add 'put' option. > (try-import): Add variable. > * doc/guix.texi (Invoking guix import): Describe 'put' option. > > Change-Id: Ied4fc95899c31fb2523a01139780fc9744aa63cb Nice! This can certainly simplify people=E2=80=99s work! > @example > -guix import @var{importer} @var{options}@dots{} > +guix import @var{option} @var{importer} @var{options}@dots{} Uh? It looks weird at first. :-) For clarity, we should change it to something like: guix import [@var{global-options}@dots{}] @var{importer} @var{package} [@= var{options}@dots{}] =E2=80=A6 though I admit this doesn=E2=80=99t look great either. > +@item --put=3D@var{file} > +@itemx -p @var{file} > +Insert the package definition(s) that the @var{importer} generated into = the How about calling it =E2=80=98--insert=E2=80=99? It seems more natural. > +(define (try-import importer args finish) Please add a docstring for top-level procedures like this one: https://guix.gnu.org/manual/devel/en/html_node/Formatting-Code.html > + (if (member importer importers) > + (match (apply (resolve-importer importer) args) Indentation of the second line is off. > + ((and expr ('package _ ...)) > + (finish (package->definition expr))) > + ((and expr (or ('let _ ...) > + ('define-public _ ...))) > + (finish expr)) Again (let =E2=80=A6) should be treated like (package =E2=80=A6). > + ((? list? expressions) > + (for-each (lambda (expr) > + (match expr > + ((and expr ('package _ ...)) > + (finish (package->definition expr))) > + ((and expr (or ('let _ ...) > + ('define-public _ ...))) > + (finish expr)))) Likewise. Also indentation of =E2=80=98match=E2=80=99 and that of the subs= equent clauses is off. > - ((or ("-h") ("--help")) > + ((or ("-h" _ ...) ("--help" _ ...)) > (leave-on-EPIPE (show-help)) > (exit 0)) > - ((or ("-V") ("--version")) > + ((or ("-V" _ ...) ("--version" _ ...)) > (show-version-and-exit "guix import")) This change seems to be unrelated, right? > + ((or ("-p" module importer args ...) > + ("--put" module importer args ...)) > + (let ((put (lambda (expr) > + (let ((line > + (call-with-input-file module > + (lambda (port) > + (do ((se (read-syntax port) > + (read-syntax port))) > + ((match (syntax->datum se) > + (('define-public symbol _ ...) > + (string> (symbol->string symbol) > + (symbol->string (cadr expr)))) > + ((? eof-object?) #t) > + (_ #f)) > + (if (eof-object? se) > + #f > + (car (string-split > + (object->string* > + (syntax->datum se) 0) > + #\newline))))))))) > + (if line > + (substitute* module > + (((string-append "\\" line)) > + (string-append > + (object->string* expr 0) > + "\n\n" line))) > + (let ((port (open-file module "a"))) > + (pretty-print-with-comments port expr) > + (newline port) > + (close-port port))))))) This whole thing should be in a separate procedure, probably in (guix utils), close to =E2=80=98edit-expression=E2=80=99, and we could call it =E2=80=98insert-expression=E2=80=99 and it would take the location where th= e caller wants to insert an expression. Then, separately, we need a procedure to determine that location based on the alphabetical order to top-level =E2=80=98define-public=E2=80=99 occu= rrences. Does that make sense? We should try and add tests for these in =E2=80=98tests/utils.scm=E2=80=99. Also please check out the coding style regarding use of =E2=80=98car=E2=80= =99 etc.: https://guix.gnu.org/manual/devel/en/html_node/Data-Types-and-Pattern-Mat= ching.html Could you send an updated series? Please let us know if anything=E2=80=99s unclear or if you need guidance. Thank you! Ludo=E2=80=99.