all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Eric Bavier <ericbavier@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] list-packages: Display package usage count.
Date: Sat, 25 Oct 2014 23:47:02 +0200	[thread overview]
Message-ID: <87siibstyh.fsf@gnu.org> (raw)
In-Reply-To: <87wq7uu0ga.fsf@member.fsf.org> (Eric Bavier's message of "Mon, 20 Oct 2014 12:15:33 -0500")

Eric Bavier <ericbavier@gmail.com> 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 <bavier@member.fsf.org>
> 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 (= n 1) "package" "packages")))))

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 not #f,
>  then only return packages whose version is equal to VERSION."
> @@ -207,6 +208,9 @@ then only return packages whose version is equal to VERSION."
>                      matching)
>              matching)))))
>  
> +(define find-packages-by-name  (find-packages fold-packages))
> +(define find-packages-by-name* (find-packages fold-packages*))

‘fold-packages*’ is the variant that also looks for private packages,
right? (It’s from one of the recent patches that hasn’t made it yet.)

But perhaps this is not needed, depending on the answer to the comment
above.  :-)

Thanks,
Ludo’.

  reply	other threads:[~2014-10-25 21:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 17:15 [PATCH] list-packages: Display package usage count Eric Bavier
2014-10-25 21:47 ` Ludovic Courtès [this message]
2014-10-26 18:23   ` Eric Bavier
2014-10-26 19:46     ` Mark H Weaver
2014-10-26 20:22       ` Eric Bavier
2014-10-26 21:17         ` 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=87siibstyh.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=ericbavier@gmail.com \
    --cc=guix-devel@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.