From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Marusich Subject: bug#35588: [PATCH] ui: Search matches additional package outputs. Date: Mon, 06 May 2019 17:57:46 -0700 Message-ID: <87zhnzxer9.fsf@gmail.com> References: <87r29czo6e.fsf@gmail.com> <20190505214153.32372-1-me@tobias.gr> <87bm0g6jbp.fsf@garuda.local.i-did-not-set--mail-host-address--so-tickle-me> <87muk0kjxf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:39918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNoRk-00070x-VA for bug-guix@gnu.org; Mon, 06 May 2019 20:59:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNoRj-0001EA-9w for bug-guix@gnu.org; Mon, 06 May 2019 20:59:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44307) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNoRi-0001Df-DI for bug-guix@gnu.org; Mon, 06 May 2019 20:59:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hNoRi-0003hv-CA for bug-guix@gnu.org; Mon, 06 May 2019 20:59:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87muk0kjxf.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 06 May 2019 11:32:12 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 35588@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: > Could we have just this hunk or is there something I=E2=80=99m missing th= at > would make it insufficient? That hunk alone is not enough, but I think the attached patch would do the trick. We just need to allow for the new possibility that the "field" procedure returns a list of strings. What do you think? =2D-=20 Chris --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-ui-Make-package-outputs-searchable.patch Content-Transfer-Encoding: quoted-printable From=20c1150a217a416ef4ceccf87c56e36e8e921f873a Mon Sep 17 00:00:00 2001 From: Chris Marusich Date: Mon, 6 May 2019 01:51:30 -0700 Subject: [PATCH] ui: Make package outputs searchable. * guix/ui.scm (relevance): Allow the "field" procedure of a metric to return a list, and handle that case appropriately. Update docstring. (%package-metrics): Add a metric for package outputs. * guix/scripts/package.scm (find-packages-by-description): Update docstring. Co-authored-by: Tobias Geerinckx-Rice =2D-- guix/scripts/package.scm | 6 +++--- guix/ui.scm | 24 +++++++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index aa27984ea2..06e4cf5b9c 100644 =2D-- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -180,9 +180,9 @@ hooks\" run when building the profile." ;;; =20 (define (find-packages-by-description regexps) =2D "Return two values: the list of packages whose name, synopsis, or =2Ddescription matches at least one of REGEXPS sorted by relevance, and the= list =2Dof relevance scores." + "Return two values: the list of packages whose name, synopsis, descripti= on, +or output matches at least one of REGEXPS sorted by relevance, and the lis= t of +relevance scores." (let ((matches (fold-packages (lambda (package result) (if (package-superseded package) result diff --git a/guix/ui.scm b/guix/ui.scm index 92c845e944..b7ccd8312a 100644 =2D-- a/guix/ui.scm +++ b/guix/ui.scm @@ -11,6 +11,8 @@ ;;; Copyright =C2=A9 2016 Benz Schenk ;;; Copyright =C2=A9 2018 Kyle Meyer ;;; Copyright =C2=A9 2018 Ricardo Wurmus +;;; Copyright =C2=A9 2019 Chris Marusich +;;; Copyright =C2=A9 2019 Tobias Geerinckx-Rice ;;; ;;; This file is part of GNU Guix. ;;; @@ -1370,9 +1372,9 @@ WIDTH columns. EXTRA-FIELDS is a list of symbol/valu= e pairs to emit." (define (relevance obj regexps metrics) "Compute a \"relevance score\" for OBJ as a function of its number of matches of REGEXPS and accordingly to METRICS. METRICS is list of =2Dfield/weight pairs, where FIELD is a procedure that returns a string =2Ddescribing OBJ, and WEIGHT is a positive integer denoting the weight of = this =2Dfield in the final score. +field/weight pairs, where FIELD is a procedure that returns a string or li= st +of strings describing OBJ, and WEIGHT is a positive integer denoting the +weight of this field in the final score. =20 A score of zero means that OBJ does not match any of REGEXPS. The higher = the score, the more relevant OBJ is to REGEXPS." @@ -1394,8 +1396,11 @@ score, the more relevant OBJ is to REGEXPS." ((field . weight) (match (field obj) (#f relevance) =2D (str (+ relevance =2D (* (score str) weight))))))) + ((? string? str) (+ relevance + (* (score str) weight))) + ((? list? lst) (+ relevance + (* weight + (apply + (map score lst))))))))) 0 metrics)) =20 @@ -1404,6 +1409,15 @@ score, the more relevant OBJ is to REGEXPS." ;; of regexps. `((,package-name . 4) =20 + ;; Match against uncommon outputs. + (,(lambda (package) + (filter (lambda (output) + (not (member output + ;; Some common outpus shared by many packag= es. + '("out" "debug" "doc" "static")))) + (package-outputs package))) + . 1) + ;; Match regexps on the raw Texinfo since formatting it is quite expen= sive ;; and doesn't have much of an effect on search results. (,(lambda (package) =2D-=20 2.20.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEy/WXVcvn5+/vGD+x3UCaFdgiRp0FAlzQ2AoACgkQ3UCaFdgi Rp1pqxAAlaBwzbBdkq1QL3T+eJusUlwMF3PV/2SPXlnGxO90Hl5Vlpcxx5v1CN2S ZCwQR5twjWhG6LuwuTCpaJ8XDUcseJIXY335Sq2TCRTbkYxugFltWGONpXBTERIm KlpGW2cRUsO+NWgi3Hdy/oC5PcY7kS/z2S74002M9Z0qcx4LuiKIG06hIsi2yMxn j3tBKcqk+DSr3PjG/HghSvb1W9Bisltq0S7NKOOWL1o1TFVGnsRScRFsCQVNn8Cp jwpc10TSVW02xdfIJwJcmQxE4nI4GtMTBGPzn5Bg/myuOlhgRk6N+YIannQ8EHhx G1otQDSoCoLsEiuX+a0SUaEKQ4LpNO0HjbgucsFDqJhbcTHLYZtx22AbvR6ckpiK F82mU8Oh2fBGLLnh1siNI7WXoFp/iGN2oFHcRqgLVqFRScvz9kDS/HKtnS+eQsbU fLBCFJ6YkaLJ2XqXVdOr6CrwC4UGEW52EBIPn361VAB5/4HKZQw71LFxICDDkyrB P5PJuTUS30SwnU+IG3Pm1xHA/PiWYE/EKc2ipZOPLLE7cT4iG3x1IMhvvmHFGawC /HhzMTjmwLw3Qn7kvhphKUAOWfNv5ZV1l8BtIqRBqK9mh1Kl6OLUkai8kSLjfF5/ xQgeI9A8WRRP4D0VK+oy9LnESG6i5yOJpP+mVEuTHXVTHg5YpZU= =0Ax+ -----END PGP SIGNATURE----- --==-=-=--