From patchwork Sun Sep 5 14:05:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 32641 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7E42D27BBE4; Sun, 5 Sep 2021 15:06:40 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id DA3C227BBE3 for ; Sun, 5 Sep 2021 15:06:39 +0100 (BST) Received: from localhost ([::1]:59376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMsn9-0001yA-0D for patchwork@mira.cbaines.net; Sun, 05 Sep 2021 10:06:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMsmY-0001uJ-V9 for guix-patches@gnu.org; Sun, 05 Sep 2021 10:06:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMsmY-0002HI-Nj for guix-patches@gnu.org; Sun, 05 Sep 2021 10:06:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mMsmY-0002MJ-CA for guix-patches@gnu.org; Sun, 05 Sep 2021 10:06:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50401] [PATCH] scripts: import: Increase column width for pretty-printer. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 05 Sep 2021 14:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50401 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50401@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16308507509046 (code B ref -1); Sun, 05 Sep 2021 14:06:02 +0000 Received: (at submit) by debbugs.gnu.org; 5 Sep 2021 14:05:50 +0000 Received: from localhost ([127.0.0.1]:50762 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMsmI-0002Lm-Gw for submit@debbugs.gnu.org; Sun, 05 Sep 2021 10:05:50 -0400 Received: from lists.gnu.org ([209.51.188.17]:33914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMsmG-0002Lf-Ix for submit@debbugs.gnu.org; Sun, 05 Sep 2021 10:05:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMsmG-0001XV-B5 for guix-patches@gnu.org; Sun, 05 Sep 2021 10:05:44 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:58618 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMsmD-00021r-I2 for guix-patches@gnu.org; Sun, 05 Sep 2021 10:05:43 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1630850737; bh=agj9Tau6qkElWA923gRN+UjupO0zTBcsXY+QPlqNs3Y=; h=From:To:Subject:Date; b=OhnVLfKMgqRX2oez8VmnvpWpcf1wKtqGUxgqaxuALtbHDmadhTP3hOz9sdKzdZJ/j wQREiIyRCpE4jy9UXk+6CukDziJlJUNW4ZZQ9v/VSoRMFNsstklm28Vhw4AV/EeBep /+LQ6xurMnbkYlqN3O+t1xuoNckPAmAxxDjDI/Lg= Message-Id: <3418edcdafdf9b6551759f4a392d8d3466f255c4.1630850420.git.public@yoctocell.xyz> Date: Sun, 05 Sep 2021 16:05:36 +0200 MIME-Version: 1.0 Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 30 X-Spam_score: 3.0 X-Spam_bar: +++ X-Spam_report: (3.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.5, FROM_SUSPICIOUS_NTLD_FP=1.599, PDS_OTHER_BAD_TLD=1.999, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Previously, the max column width for the pretty-printer was 50, which caused generated package definitions to include unnecessary newlines, e.g., (home-page "https://gitlab.com/ttyperacer/terminal-typeracer") instead of (home-page "https://gitlab.com/ttyperacer/terminal-typeracer") * guix/scripts/import.scm (guix-import): Set max expression width to 80 when pretty-printing. --- I don’t know if there is an official stance on the column width, but I most people seem to go with 80. Before, a generated package definition might look like this --8<---------------cut here---------------start------------->8--- (define-public rust-typeracer-2 (package (name "rust-typeracer") (version "2.0.7") (source (origin (method url-fetch) (uri (crate-uri "typeracer" version)) (file-name ; unnecessary newline here (string-append name "-" version ".tar.gz")) (sha256 (base32 "1q1f6aslmqab8kqds6azsz7li0r5z7alqar17r1d675vsqfiidml")))) (build-system cargo-build-system) (arguments `(#:cargo-inputs (("rust-clap" ,rust-clap-2) ("rust-directories-next" ,rust-directories-next-2) ("rust-git2" ,rust-git2-0.13) ("rust-itertools" ,rust-itertools-0.10) ("rust-rand" ,rust-rand-0.8) ("rust-refinery" ,rust-refinery-0.5) ("rust-rusqlite" ,rust-rusqlite-0.24) ("rust-serde" ,rust-serde-1) ("rust-termion" ,rust-termion-1) ("rust-toml" ,rust-toml-0.5) ("rust-tui" ,rust-tui-0.9) ("rust-unicode-segmentation" ,rust-unicode-segmentation-1) ("rust-unicode-width" ,rust-unicode-width-0.1)))) (home-page ; and here "https://gitlab.com/ttyperacer/terminal-typeracer") (synopsis "A terminal typing game. Race to see the fastest time you can get!") (description "This package provides a terminal typing game. Race to see the fastest time you can get!") (license license:gpl3))) --8<---------------cut here---------------end--------------->8--- With the patch applied --8<---------------cut here---------------start------------->8--- (define-public rust-typeracer-2 (package (name "rust-typeracer") (version "2.0.7") (source (origin (method url-fetch) (uri (crate-uri "typeracer" version)) ;; No newline this time. (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "1q1f6aslmqab8kqds6azsz7li0r5z7alqar17r1d675vsqfiidml")))) (build-system cargo-build-system) (arguments `(#:cargo-inputs (("rust-clap" ,rust-clap-2) ("rust-directories-next" ,rust-directories-next-2) ("rust-git2" ,rust-git2-0.13) ("rust-itertools" ,rust-itertools-0.10) ("rust-rand" ,rust-rand-0.8) ("rust-refinery" ,rust-refinery-0.5) ("rust-rusqlite" ,rust-rusqlite-0.24) ("rust-serde" ,rust-serde-1) ("rust-termion" ,rust-termion-1) ("rust-toml" ,rust-toml-0.5) ("rust-tui" ,rust-tui-0.9) ("rust-unicode-segmentation" ,rust-unicode-segmentation-1) ("rust-unicode-width" ,rust-unicode-width-0.1)))) ;; Here too! (home-page "https://gitlab.com/ttyperacer/terminal-typeracer") (synopsis "A terminal typing game. Race to see the fastest time you can get!") (description "This package provides a terminal typing game. Race to see the fastest time you can get!") (license license:gpl3))) --8<---------------cut here---------------end--------------->8--- guix/scripts/import.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) base-commit: 9540323458de87b0b8aa421e449a4fe27af7c393 diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm index b369a362d0..73508bade2 100644 --- a/guix/scripts/import.scm +++ b/guix/scripts/import.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2014 David Thompson ;;; Copyright © 2018 Kyle Meyer ;;; Copyright © 2019 Ricardo Wurmus +;;; Copyright © 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -117,7 +118,8 @@ Run IMPORTER with ARGS.\n")) (if (member importer importers) (let ((print (lambda (expr) (pretty-print expr (newline-rewriting-port - (current-output-port)))))) + (current-output-port)) + #:max-expr-width 80)))) (match (apply (resolve-importer importer) args) ((and expr (or ('package _ ...) ('let _ ...)