all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Xinglu Chen <public@yoctocell.xyz>
To: 50401@debbugs.gnu.org
Subject: [bug#50401] [PATCH] scripts: import: Increase column width for pretty-printer.
Date: Sun, 05 Sep 2021 16:05:36 +0200	[thread overview]
Message-ID: <3418edcdafdf9b6551759f4a392d8d3466f255c4.1630850420.git.public@yoctocell.xyz> (raw)

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







             reply	other threads:[~2021-09-05 14:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05 14:05 Xinglu Chen [this message]
2021-09-14  9:11 ` bug#50401: [PATCH] scripts: import: Increase column width for pretty-printer Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3418edcdafdf9b6551759f4a392d8d3466f255c4.1630850420.git.public@yoctocell.xyz \
    --to=public@yoctocell.xyz \
    --cc=50401@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.