From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 2NgEIosJTWNGegEAbAwnHQ (envelope-from ) for ; Mon, 17 Oct 2022 09:51:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iH8iIYsJTWM6egEAG6o9tA (envelope-from ) for ; Mon, 17 Oct 2022 09:51:39 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 1D0F23C06D for ; Mon, 17 Oct 2022 09:51:39 +0200 (CEST) Received: from localhost ([::1]:46762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okKuQ-0003gk-1n for larch@yhetil.org; Mon, 17 Oct 2022 03:51:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okKpz-0005l0-4V for guix-patches@gnu.org; Mon, 17 Oct 2022 03:47:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okKpy-0004Cv-R8 for guix-patches@gnu.org; Mon, 17 Oct 2022 03:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1okKpy-0002uT-Fw for guix-patches@gnu.org; Mon, 17 Oct 2022 03:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58136] [PATCH] ui: Improve sort order when searching package names. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 17 Oct 2022 07:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58136 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Lars-Dominik Braun Cc: 58136@debbugs.gnu.org, zimoun Received: via spool by 58136-submit@debbugs.gnu.org id=B58136.166599280611159 (code B ref 58136); Mon, 17 Oct 2022 07:47:02 +0000 Received: (at 58136) by debbugs.gnu.org; 17 Oct 2022 07:46:46 +0000 Received: from localhost ([127.0.0.1]:47095 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okKpi-0002tu-Ak for submit@debbugs.gnu.org; Mon, 17 Oct 2022 03:46:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okKpY-0002tU-Qv for 58136@debbugs.gnu.org; Mon, 17 Oct 2022 03:46:44 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44680) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okKpT-0004AV-Dx; Mon, 17 Oct 2022 03:46:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=pfGgB/5PdQvGBe2B8ocanGYNcy8t+NYFsPmYNLL4jeA=; b=EkQshrDvSmJzP5THnbTf yqZFTUsBzYhjOpwYTcOhJZhC0GgEO1qem+mTaMXHRf7Pgx3r/FMn69X/4cqpPgxYVftwAgoaio2lS muZ/Fph9hgSBy1EVPm1TUL+qHO228rwK+DVnzujY/2PvVdc0FDccDaD1sg0VO664mjV0ID614FlcW SZD7YqesceN6GQ8Z9axRcmaZnct+wYkq3riUncJOqCXgMyrsjdDocWhwmqjWeUKTs5P39xs5SHBvl CBsQBvNmlttce/nMFASx+oz5uoZpWHf1c5Jam9nJE7ay2nPDCKV3pHwtC4oYFkCRzzoneTbP1sKmc 92BIUf3VkgClCQ==; Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=52172 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okKpS-0007dy-Oj; Mon, 17 Oct 2022 03:46:30 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <86wn9na82p.fsf@gmail.com> Date: Mon, 17 Oct 2022 09:46:28 +0200 In-Reply-To: (Lars-Dominik Braun's message of "Wed, 12 Oct 2022 13:24:08 +0200") Message-ID: <8735bmj3jf.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665993099; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=pfGgB/5PdQvGBe2B8ocanGYNcy8t+NYFsPmYNLL4jeA=; b=fUyYlrO903gL39OieGFBhytAVzGXmYc6W5XnhCZDYxP5StZ8/5iluTXvlgXFQznz3/d+nW fnsW/HFepEQ1uZWwzZgbUfyd930c24x7lmanAh80QS+XSHXdAD513YudSg2VC+NnFQ5QRW dPQ0ggErkdqgaBv3BGBnSq6SXOAJD5vu1phpGQWcqVEf1GRk6Yhu5f0e6F98I5fEj/q9tE N631YOk7x7dY2xRhGtpMwIcCQcM+BrxqhwDmvukjge8QzbEHy7N10KrvCePx6igs1qMhvd wJSBybNVijw5A/WFceDAJfc/tO8r/yKClnaMt9+w5mwGlGfJ3qmhsAWJ8S4orw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665993099; a=rsa-sha256; cv=none; b=IvW/nKs/LMGjpcbuJ99uQOwDRA2ylmIV5H1Ferxn7W/JYgkFAXg1L5/a8Th1FVmPRlRM4H g4VO3wWd2HxatLZMfRMEakx6xTxLbcH2rCgS8Rv6zQw0thlLHKkLuc4dqbqxhcICLnd8ni pKBXxSk18BO3fmun9mTuogkF2/NhTJHNaOca3922oIHaRFV5lWRuMTdmILkWji3aKSMOmG OSInre07g+tuRLGsLKL28y3PxaqcmwSy38idOCWPS83ymRZ6omUNsPfd2TYvXc1VtU1ghO uZEVS+LC2QvGocPz5LavtZtl7AboNieugdETcbGJ8sl4quR8Ra+Ggdsh+HxkXg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=EkQshrDv; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.82 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=EkQshrDv; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 1D0F23C06D X-Spam-Score: -3.82 X-Migadu-Scanner: scn1.migadu.com X-TUID: rsku85RgKTAE Hi! Lars-Dominik Braun skribis: > diff --git a/guix/packages.scm b/guix/packages.scm > index 94e464cd01..9934501cdb 100644 > --- a/guix/packages.scm > +++ b/guix/packages.scm > @@ -86,6 +86,7 @@ (define-module (guix packages) > this-package > package-name > package-upstream-name > + package-upstream-name* > package-version > package-full-name > package-source > @@ -657,6 +658,38 @@ (define (package-upstream-name package) > (or (assq-ref (package-properties package) 'upstream-name) > (package-name package))) >=20=20 > +(define (package-upstream-name* package) > + "Return the upstream name of PACKAGE, which could be different from th= e name > +it has in Guix." s/which could.*Guix/accounting for commonly-used package name prefixes in addition to the @code{upstream-name} property/ Preferably make this addition in a separate commit. > +++ b/guix/ui.scm > @@ -1623,10 +1623,23 @@ (define (relevance obj regexps metrics) > (define (score regexp str) > (fold-matches regexp str 0 > (lambda (m score) > - (+ score > - (if (string=3D? (match:substring m) str) > - 5 ;exact match > - 1))))) > + (let* ((start (- (match:start m) 1)) > + (end (match:end m)) > + (left (if (>=3D start 0) (string-ref str star= t) #f)) > + (right (if (< end (string-length str)) (strin= g-ref str end) #f)) > + (delimiter-classes '(Cc Cf Pd Pe Pf Pi Po Ps = Sk Zs Zl Zp)) > + (delim-left (or (member (and=3D> left char-ge= neral-category) delimiter-classes) (eq? left #f))) > + (delim-right (or (member (and=3D> right char-= general-category) delimiter-classes) (eq? right #f)))) > + (max score > + (cond > + ;; regexp is a full match for str. > + ((and (eq? left #f) (eq? right #f)) 4) > + ;; regexp matches a single word in str. > + ((and delim-left delim-right) 3) > + ;; regexp matches the beginning or end of a wo= rd in str. > + ((or delim-left delim-right) 2) > + ;; Everything else. > + (#t 1))))))) The intent is to have all regexps behave as if the user passed \, is that right? Would be nice to have a comment clarifying that above and perhaps making it a separate change? Stylistic notes: (if cond consequent #f) =3D> (and cond consequent) (eq? x #f) =3D> (not x) (cond =E2=80=A6 (#t x)) =3D> (cond =E2=80=A6 (else x)) > @@ -1635,10 +1648,11 @@ (define (regexp->score regexp) > ((field . weight) > (match (field obj) > (#f relevance) > + ('() relevance) > ((? string? str) > - (+ relevance (* (score-regexp str) weight))) > + (max relevance (* (score-regexp str) weight))) > ((lst ...) > - (+ relevance (* weight (apply + (map score-regexp ls= t))))))))) > + (max relevance (* weight (apply max (map score-regex= p lst))))))))) Intuitively I would expect scores to add up, otherwise we=E2=80=99re kinda losing information; so I would not make this change. WDYT? There=E2=80=99s a test for =E2=80=98package-relevance=E2=80=99 in tests/ui.= scm. Please make sure it still passes and ideally add relevant tests such as the CSV example you gave. Thanks! Ludo=E2=80=99.