From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] list-packages: Display package usage count. Date: Sat, 25 Oct 2014 23:47:02 +0200 Message-ID: <87siibstyh.fsf@gnu.org> References: <87wq7uu0ga.fsf@member.fsf.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]:45968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi9Ah-00069J-1u for guix-devel@gnu.org; Sat, 25 Oct 2014 17:46:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xi9Ac-0000qo-16 for guix-devel@gnu.org; Sat, 25 Oct 2014 17:46:51 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:40510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi9Ab-0000qZ-RF for guix-devel@gnu.org; Sat, 25 Oct 2014 17:46:45 -0400 In-Reply-To: <87wq7uu0ga.fsf@member.fsf.org> (Eric Bavier's message of "Mon, 20 Oct 2014 12:15:33 -0500") 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-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Eric Bavier Cc: guix-devel@gnu.org Eric Bavier skribis: > This patch adds a simple message like "used by X other packages" to each > packages description on > https://www.gnu.org/software/guix/package-list.html. Nice. > From 41a3599bcdc3888085379801e9a7f05430ffe0c3 Mon Sep 17 00:00:00 2001 > From: Eric Bavier > Date: Mon, 20 Oct 2014 12:12:28 -0500 > Subject: [PATCH] list-packages: Display package usage count. > > * gnu/packages.scm (find-packages, find-package-by-name*): New > procedures. > * build-aux/list-packages.scm (package->sxml)[users]: New local > procedure. [...] > + (define (users package) > + (let ((n (length (package-transitive-dependents > + (find-packages-by-name* (package-name package) > + (package-version package))= )))) Why not just (package-transitive-dependents package)? > + (and (> n 0) > + `(div "used by " ,n " other " ,(if (=3D n 1) "package" "packa= ges"))))) Good. > -(define find-packages-by-name > +(define (find-packages fold) > (let ((packages (delay > - (fold-packages (lambda (p r) > - (vhash-cons (package-name p) p r)) > - vlist-null)))) > + (fold (lambda (p r) > + (vhash-cons (package-name p) p r)) > + vlist-null)))) > (lambda* (name #:optional version) > "Return the list of packages with the given NAME. If VERSION is n= ot #f, > then only return packages whose version is equal to VERSION." > @@ -207,6 +208,9 @@ then only return packages whose version is equal to V= ERSION." > matching) > matching))))) >=20=20 > +(define find-packages-by-name (find-packages fold-packages)) > +(define find-packages-by-name* (find-packages fold-packages*)) =E2=80=98fold-packages*=E2=80=99 is the variant that also looks for private= packages, right? (It=E2=80=99s from one of the recent patches that hasn=E2=80=99t mad= e it yet.) But perhaps this is not needed, depending on the answer to the comment above. :-) Thanks, Ludo=E2=80=99.