From: Chris Marusich <cmmarusich@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 35588@debbugs.gnu.org
Subject: bug#35588: [PATCH] ui: Search matches additional package outputs.
Date: Mon, 06 May 2019 17:57:46 -0700 [thread overview]
Message-ID: <87zhnzxer9.fsf@gmail.com> (raw)
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")
[-- Attachment #1.1: Type: text/plain, Size: 371 bytes --]
Ludovic Courtès <ludo@gnu.org> writes:
> Could we have just this hunk or is there something I’m missing that
> 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?
--
Chris
[-- Attachment #1.2: 0001-ui-Make-package-outputs-searchable.patch --]
[-- Type: text/x-patch, Size: 3991 bytes --]
From c1150a217a416ef4ceccf87c56e36e8e921f873a Mon Sep 17 00:00:00 2001
From: Chris Marusich <cmmarusich@gmail.com>
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 <me@tobias.gr>
---
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
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -180,9 +180,9 @@ hooks\" run when building the profile."
;;;
(define (find-packages-by-description regexps)
- "Return two values: the list of packages whose name, synopsis, or
-description matches at least one of REGEXPS sorted by relevance, and the list
-of relevance scores."
+ "Return two values: the list of packages whose name, synopsis, description,
+or output matches at least one of REGEXPS sorted by relevance, and the list 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
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -11,6 +11,8 @@
;;; Copyright © 2016 Benz Schenk <benz.schenk@uzh.ch>
;;; Copyright © 2018 Kyle Meyer <kyle@kyleam.com>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2019 Chris Marusich <cmmarusich@gmail.com>
+;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -1370,9 +1372,9 @@ WIDTH columns. EXTRA-FIELDS is a list of symbol/value 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
-field/weight pairs, where FIELD is a procedure that returns a string
-describing OBJ, and WEIGHT is a positive integer denoting the weight of this
-field in the final score.
+field/weight pairs, where FIELD is a procedure that returns a string or list
+of strings describing OBJ, and WEIGHT is a positive integer denoting the
+weight of this field in the final score.
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)
- (str (+ relevance
- (* (score str) weight)))))))
+ ((? string? str) (+ relevance
+ (* (score str) weight)))
+ ((? list? lst) (+ relevance
+ (* weight
+ (apply + (map score lst)))))))))
0
metrics))
@@ -1404,6 +1409,15 @@ score, the more relevant OBJ is to REGEXPS."
;; of regexps.
`((,package-name . 4)
+ ;; Match against uncommon outputs.
+ (,(lambda (package)
+ (filter (lambda (output)
+ (not (member output
+ ;; Some common outpus shared by many packages.
+ '("out" "debug" "doc" "static"))))
+ (package-outputs package)))
+ . 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.20.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2019-05-07 0:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-05 19:39 bug#35588: guix package --search does not search output names Chris Marusich
2019-05-05 21:41 ` bug#35588: [PATCH] ui: Search matches additional package outputs Tobias Geerinckx-Rice
2019-05-06 9:08 ` Chris Marusich
2019-05-06 9:32 ` Ludovic Courtès
2019-05-07 0:57 ` Chris Marusich [this message]
2019-05-07 8:25 ` Ludovic Courtès
2019-05-08 6:50 ` bug#35588: [PATCH] ui: Search matches additional package outputs., " Chris Marusich
2019-05-08 10:39 ` Ludovic Courtès
2019-05-09 7:22 ` Chris Marusich
2019-05-07 22:24 ` swedebugia
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=87zhnzxer9.fsf@gmail.com \
--to=cmmarusich@gmail.com \
--cc=35588@debbugs.gnu.org \
--cc=ludo@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.