GNU bug report logs - #50401
[PATCH] scripts: import: Increase column width for pretty-printer.

Previous Next

Package: guix-patches;

Reported by: Xinglu Chen <public <at> yoctocell.xyz>

Date: Sun, 5 Sep 2021 14:06:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50401 in the body.
You can then email your comments to 50401 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#50401; Package guix-patches. (Sun, 05 Sep 2021 14:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Xinglu Chen <public <at> yoctocell.xyz>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 05 Sep 2021 14:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Xinglu Chen <public <at> yoctocell.xyz>
To: guix-patches <at> gnu.org
Subject: [PATCH] scripts: import: Increase column width for pretty-printer.
Date: Sun, 05 Sep 2021 16:05:36 +0200
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(-)

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 <davet <at> gnu.org>
 ;;; Copyright © 2018 Kyle Meyer <kyle <at> kyleam.com>
 ;;; Copyright © 2019 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Xinglu Chen <public <at> yoctocell.xyz>
 ;;;
 ;;; 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 _ ...)

base-commit: 9540323458de87b0b8aa421e449a4fe27af7c393
-- 
2.33.0







Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Tue, 14 Sep 2021 09:12:02 GMT) Full text and rfc822 format available.

Notification sent to Xinglu Chen <public <at> yoctocell.xyz>:
bug acknowledged by developer. (Tue, 14 Sep 2021 09:12:02 GMT) Full text and rfc822 format available.

Message #10 received at 50401-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Xinglu Chen <public <at> yoctocell.xyz>
Cc: 50401-done <at> debbugs.gnu.org
Subject: Re: bug#50401: [PATCH] scripts: import: Increase column width for
 pretty-printer.
Date: Tue, 14 Sep 2021 11:11:33 +0200
Hi,

Xinglu Chen <public <at> yoctocell.xyz> skribis:

> 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.

Applied!

I wonder why we never realized before…  Thank you!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 12 Oct 2021 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 197 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.