From: ludo@gnu.org (Ludovic Courtès)
To: Nikita Karetnikov <nikita@karetnikov.org>
Cc: bug-guix@gnu.org
Subject: Re: guix-package --search
Date: Mon, 21 Jan 2013 23:13:24 +0100 [thread overview]
Message-ID: <87obgi6v7f.fsf@gnu.org> (raw)
In-Reply-To: <87r4lfr0r3.fsf@karetnikov.org> (Nikita Karetnikov's message of "Sun, 20 Jan 2013 16:40:38 -0500")
Hi,
Nikita Karetnikov <nikita@karetnikov.org> skribis:
> 1. 'psd-list' is a potential bottleneck. It will cause problems when we
> have more packages. If it's possible to evaluate it lazily, I'll
> rewrite it. (I haven't checked yet.)
See below.
[...]
> 4. I've noticed that 'fold-packages' returns duplicates. Should it be
> fixed? Should I filter the output instead?
These are not really duplicates, actually: these are variants of the
same packages, created using ‘inherit’, and keeping the original
package’s source location info (which could be fixed).
That said, it would make sense to ‘delete-duplicates’ any two packages
whose ‘package-location’ are ‘eq?’. But that can be left as a separate
commit.
The patch looks good overall. A few comments:
> +(define (sd-search rx)
Rather ‘find-packages-by-description’ or similar.
> + "Search in SYNOPSIS and DESCRIPTION using RX. Return a list of
> +matching packages."
> + (define psd-list
> + ;; Return a list of lists (each inner list contains PACKAGE-NAME,
> + ;; SYNOPSIS, and DESCRIPTION of every package).
> + (map (lambda (x)
> + (list x (package-synopsis x) (package-description x)))
> + (fold-packages cons '())))
Instead, you can directly build the list of matching packages, like:
(fold-packages (lambda (package result)
(if (or (regexp-exec rx (package-synopsis package))
(regexp-exec rx (package-description package)))
(cons package result)
result))
'())
This way, only one traversal is done.
For i18n, we should actually use (gettext (package-description
package)), likewise for synopsis. This way, that will search through
text in the user’s native language.
> + (('search regexp)
> + (let ((regexp (and regexp (make-regexp regexp))))
> + (for-each (lambda (p)
> + (format #t "~a\t~a\t~a~%"
> + (package-name p)
> + (package-version p)
> + (location->string (package-location p))))
> + (sd-search regexp))
> + #t))
Perfect.
Thanks!
Ludo’.
next prev parent reply other threads:[~2013-01-21 22:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-20 3:15 guix-package --search Nikita Karetnikov
2013-01-20 21:40 ` Nikita Karetnikov
2013-01-21 22:13 ` Ludovic Courtès [this message]
2013-01-23 15:33 ` Nikita Karetnikov
2013-01-24 21:14 ` Ludovic Courtès
2013-01-26 8:55 ` [PATCH] guix-package: Add '--search'. (was: guix-package --search) Nikita Karetnikov
2013-01-26 21:43 ` [PATCH] guix-package: Add '--search' 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=87obgi6v7f.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=bug-guix@gnu.org \
--cc=nikita@karetnikov.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.