From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tobias Geerinckx-Rice Subject: bug#35588: [PATCH] ui: Search matches additional package outputs. Date: Sun, 5 May 2019 23:41:53 +0200 Message-ID: <20190505214153.32372-1-me@tobias.gr> References: <87r29czo6e.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([209.51.188.92]:56581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNOua-0003sf-QJ for bug-guix@gnu.org; Sun, 05 May 2019 17:43:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNOuY-00052d-Rb for bug-guix@gnu.org; Sun, 05 May 2019 17:43:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41523) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hNOuV-0004r7-Fq for bug-guix@gnu.org; Sun, 05 May 2019 17:43:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hNOuU-0006uh-8U for bug-guix@gnu.org; Sun, 05 May 2019 17:43:02 -0400 In-Reply-To: <87r29czo6e.fsf@gmail.com> Sender: "Debbugs-submit" Resent-Message-ID: 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: 35588@debbugs.gnu.org * guix/ui.scm (%package-metrics): Add a PACKAGE-OUTPUTS metric with a relevance of 1. * guix/scripts/package.scm (process-query): Add the REGEXP/NEWLINE flag. --- mikadoZero, Guix, Here's a patch to match package outputs (except ‘out’, since it can't affect the relative score) in ‘guix search’. Before: ~ λ guix search ernel-patch # nothing After: ~ λ guix search ernel-patch name: wireguard version: 0.0.20190406 outputs: out kernel-patch … ~ λ guix search ^ernel-patch # nothing While the new REGEXP/NEWLINE flag affects how all fields are matched, I don't think it actually changes anything in practice without the second hunk. If there's a possibility that it might, I'd split this into two commits. Kind regards, T G-R guix/scripts/package.scm | 3 ++- guix/ui.scm | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index aa27984ea2..a31e78484e 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -751,7 +751,8 @@ processed, #f otherwise." (('query 'search rx) rx) (_ #f)) opts)) - (regexps (map (cut make-regexp* <> regexp/icase) patterns))) + (regexps (map (cut make-regexp* <> regexp/icase regexp/newline) + patterns))) (leave-on-EPIPE (let-values (((packages scores) (find-packages-by-description regexps))) diff --git a/guix/ui.scm b/guix/ui.scm index 92c845e944..f2466b605b 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1404,6 +1404,12 @@ score, the more relevant OBJ is to REGEXPS." ;; of regexps. `((,package-name . 4) + ;; Separate package outputs by newlines to match regexps like "^tools$". + ;; Hard-codedly ignore ‘out’ since it presumably exists for every package. + (,(lambda (package) + (string-join (delete "out" (package-outputs package)) + "\n")) . 1) + ;; Match regexps on the raw Texinfo since formatting it is quite expensive ;; and doesn't have much of an effect on search results. (,(lambda (package) -- 2.21.0