all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#50401] [PATCH] scripts: import: Increase column width for pretty-printer.
@ 2021-09-05 14:05 Xinglu Chen
  2021-09-14  9:11 ` bug#50401: " Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Xinglu Chen @ 2021-09-05 14:05 UTC (permalink / raw)
  To: 50401

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







^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#50401: [PATCH] scripts: import: Increase column width for pretty-printer.
  2021-09-05 14:05 [bug#50401] [PATCH] scripts: import: Increase column width for pretty-printer Xinglu Chen
@ 2021-09-14  9:11 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2021-09-14  9:11 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 50401-done

Hi,

Xinglu Chen <public@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’.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-14  9:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-05 14:05 [bug#50401] [PATCH] scripts: import: Increase column width for pretty-printer Xinglu Chen
2021-09-14  9:11 ` bug#50401: " Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.