From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: User-Friendlyness of Guix and non-scaryness, printing messages Date: Tue, 30 May 2017 17:11:36 +0200 Message-ID: <87efv64bx3.fsf@gnu.org> References: <87bbe3e5.AEAAKL2r-KIAAAAAAAAAAAOtUOAAAAACwQwAAAAAAAW9WABZGcQo@mailjet.com> <87y3tw4kw3.fsf@gnu.org> <87r2zfx0xt.fsf@gnu.org> <427678e8.AEUAKjfDcSgAAAAAAAAAAAPB0agAAAACwQwAAAAAAAW9WABZKceD@mailjet.com> <20170528204437.6dfd35c4@scratchpost.org> <20170528210146.530b3f17@scratchpost.org> <20170528223517.612a87df@scratchpost.org> <20170528225823.6db84e61@scratchpost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFioA-0007oK-1u for guix-devel@gnu.org; Tue, 30 May 2017 11:11:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFio6-0006vT-Ss for guix-devel@gnu.org; Tue, 30 May 2017 11:11:42 -0400 In-Reply-To: <20170528225823.6db84e61@scratchpost.org> (Danny Milosavljevic's message of "Sun, 28 May 2017 22:58:23 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Danny Milosavljevic Cc: guix-devel@gnu.org Hi Danny, Danny Milosavljevic skribis: > And also the spinner integrated: > > diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm > index f050fad97..d9ac61122 100644 > --- a/guix/scripts/package.scm > +++ b/guix/scripts/package.scm > @@ -46,6 +46,7 @@ > #:use-module (srfi srfi-34) > #:use-module (srfi srfi-35) > #:use-module (srfi srfi-37) > + #:use-module (rnrs io ports) > #:use-module (gnu packages) > #:autoload (gnu packages base) (canonical-package) > #:autoload (gnu packages guile) (guile-2.0) > @@ -187,6 +188,27 @@ denote ranges as interpreted by 'matching-generation= s'." > (else > (leave (G_ "invalid syntax: ~a~%") pattern))))) >=20=20 > +(define previous-output-port (current-error-port)) > + > +(define spinner-port > + (let ((index 0) > + (spinner-chars "|\\-/")) > + (define (spin) > + (set! index (+ index 1)) > + (if (>=3D index (string-length spinner-chars)) > + (set! index 0)) > + (display (array-ref spinner-chars index) previous-output-port) > + (display #\backspace previous-output-port) > + (flush-output-port previous-output-port)) > + (make-soft-port > + (vector > + (lambda (c) (if (char=3D? c #\newline) (spin))) ; putc > + (lambda (s) (if (string-contains s "\n") (spin))) ; puts > + (lambda () #t) ; flush > + (lambda () #f) ; getc > + (lambda () #t)) ; close > + "w"))) Nice hack! I don=E2=80=99t think we should incorporate it just right now; I would prefer something that writes =E2=80=9Cbuilding foo=E2=80=9D or =E2=80= =9Cdownloading bar=E2=80=9D in addition to the spinner, like =E2=80=98wip-ui=E2=80=99 tries to do. WDYT? Ludo=E2=80=99.