--- guix-package-orig 2013-01-20 16:43:13.000000000 +0000 +++ guix-package 2013-01-20 20:47:38.000000000 +0000 @@ -230,6 +230,32 @@ (leave (_ "error: no previous profile; not rolling back~%"))) (else (switch-link))))) +(define (sd-search rx) + "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 '()))) + + (define (matcher str) + ;; Match RX against STR. Return the result or #f if nothing was + ;; found. + (false-if-exception (match:substring (regexp-exec rx str) 0))) + + (define (package? lst) + ;; Return PACKAGE wrapped in a list or '() if match failed. + (if (any (cut matcher <>) (list (cadr lst) (caddr lst))) + (list (car lst)) + '())) + + (sort (append-map package? psd-list) + (lambda (p1 p2) + (stringstring (package-location p)))) + (sd-search regexp)) + #t)) (_ #f)))) (setlocale LC_ALL "")