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 gMkfMiwhk2NohQEAbAwnHQ (envelope-from ) for ; Fri, 09 Dec 2022 12:51:08 +0100 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 kFQ/MSwhk2MVIAAAG6o9tA (envelope-from ) for ; Fri, 09 Dec 2022 12:51:08 +0100 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 777487578 for ; Fri, 9 Dec 2022 12:51:08 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3btG-0002LP-0e; Fri, 09 Dec 2022 06:50:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3btC-0002Jt-LM for guix-patches@gnu.org; Fri, 09 Dec 2022 06:50:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p3btC-0005mw-8D for guix-patches@gnu.org; Fri, 09 Dec 2022 06:50:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3btB-0006ii-R1 for guix-patches@gnu.org; Fri, 09 Dec 2022 06:50:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#58136] [PATCH] ui: Improve sort order when searching package names. Resent-From: Lars-Dominik Braun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 09 Dec 2022 11:50:01 +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: moreinfo patch To: 58136@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , zimoun Received: via spool by 58136-submit@debbugs.gnu.org id=B58136.167058659325819 (code B ref 58136); Fri, 09 Dec 2022 11:50:01 +0000 Received: (at 58136) by debbugs.gnu.org; 9 Dec 2022 11:49:53 +0000 Received: from localhost ([127.0.0.1]:35531 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3bt2-0006iN-OL for submit@debbugs.gnu.org; Fri, 09 Dec 2022 06:49:53 -0500 Received: from mout-p-201.mailbox.org ([80.241.56.171]:37616) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3bsz-0006iF-Vz for 58136@debbugs.gnu.org; Fri, 09 Dec 2022 06:49:50 -0500 Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4NT8Sz6mkmz9sWF; Fri, 9 Dec 2022 12:49:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1670586579; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=D3UqD+JlhP4kYcsh/KroWdDOdida/vpSp/YG+jYd5Tk=; b=BPkcP1GNuojqZ7AM8WtuAdLOCt85FLpqjXIZwBWwnJWW9/5g5UKK71palcSPV5wmVNHbqv vmlByC6R54iaTTF6P1YyfkEZOPj7+Xukuy4uJIKDuP0LOYB8z+63nfuGjv43ns5M4hS2KL 4bYWBziVvuUqfCpLHnu/B+R1pp7CAIZzJHkBr7sEwRR/euIY1RstaomlOjRZMEnovXNzg4 lGYuZYmyrepCQHg92GdBACPUyBW1yKu8uo9qyrmxof0GP6DPG5vj+WZbIebcAwBXr3vNhO 0fmMaiJlqm3FGAj5NtfIvml5AUTP/faCbs42hYmIt16hoqXBRJRwFmRzZ0QiNA== Date: Fri, 9 Dec 2022 12:49:32 +0100 From: Lars-Dominik Braun Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="wmmVohns9Qrs/GFS" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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-bounces+larch=yhetil.org@gnu.org 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=1670586668; 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=D3UqD+JlhP4kYcsh/KroWdDOdida/vpSp/YG+jYd5Tk=; b=hhhtehJIH0LE0AIvt2M93hl2o2SGqMQ5OieTi/ToxVSfpurPHuOoo0Ymig3pVahrFyQZs1 +ZV7jEib7OgSYh6fuxa5yOxh6+xy2Vi7LHoDucwqzETlV60k81kC0MC8DtuDZaF7EMVp43 M0a3cRqKxJRWhB3cnitj3p0l8RniBGFtNeMkHqfmdx+TC2Ary56G71XWYSZ49oN0uzf5UC 7s+HuspQfNsJkk7HL3Qgv+u1hSEE4iIfPpoS8FwblDClbPPgP9lr01KBvvjF1vdv+ivSM7 mlxHpnfHwepfgeSYSfzZA3OkKWw/ZtcdgWeSuY8g+TZg28RnfgdPnjIxcI1+kA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1670586668; a=rsa-sha256; cv=none; b=IZI1LRE/d7XLtnnFHlFSKdezrMkAlcY1zndaGr/MYwJ5V6Bl9zTu++8j6D58RcBhrzinAp 8SHFZmt81c6DswoO0cICPIU8Mn3vhSu5htRCe6PU/N2DKmvoh4aYoqlJMt0OV62qYXY6Bc OYCvXDCvasPfssjXlfun5+N5v0+F08hAoAkVg9YWYa3zdLng7GWxarmeYbuQQUBDtDbBZF Xiop+4TN1PCuPDmZfjl4xsNRMZUqyNoTUSh0i92/yh4fTQzqQw9iO8I4dyr3uWbrFCn5oe bvfRBGdILhyiiwZ+camHM17oUW6xPT67M9V4uG523JbMcV/6oXEAL1RYmZZPXw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=6xq.net header.s=MBO0001 header.b=BPkcP1GN; dmarc=fail reason="SPF not aligned (relaxed)" header.from=6xq.net (policy=none); 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: 7.46 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=6xq.net header.s=MBO0001 header.b=BPkcP1GN; dmarc=fail reason="SPF not aligned (relaxed)" header.from=6xq.net (policy=none); 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: 777487578 X-Spam-Score: 7.46 X-Migadu-Scanner: scn1.migadu.com X-TUID: zE0FWEqnutdQ --wmmVohns9Qrs/GFS Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, attached is version 2 of my initial patch, which simply moves prefix detection into PACKAGE-UPSTREAM-NAME* (as suggested by Ludo) and reduces the score to 2 (as suggested by Simon). It’s therefore quite tailored to the “ggplot2 problem”, but does the job. Thanks, Lars --wmmVohns9Qrs/GFS Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-packages-Add-package-upstream-name.patch" >From e0092d786b29f4f1cdc35217212a86804f36cdb4 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 9 Dec 2022 11:46:37 +0100 Subject: [PATCH v2 1/2] packages: Add 'package-upstream-name*'. * guix/packages.scm (package-upstream-name*): New procedure. * tests/packages.scm ("package-upstream-name*"): New test. --- guix/packages.scm | 33 +++++++++++++++++++++++++++++++++ tests/packages.scm | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/guix/packages.scm b/guix/packages.scm index 8f119d9fa7..5e8e3a4ff4 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -89,6 +89,7 @@ (define-module (guix packages) this-package package-name package-upstream-name + package-upstream-name* package-version package-full-name package-source @@ -691,6 +692,38 @@ (define (package-upstream-name package) (or (assq-ref (package-properties package) 'upstream-name) (package-name package))) +(define (package-upstream-name* package) + "Return the upstream name of PACKAGE, accounting for commonly-used +package name prefixes in addition to the @code{upstream-name} property." + (let ((namespaces (list "cl-" + "ecl-" + "emacs-" + "ghc-" + "go-" + "guile-" + "java-" + "julia-" + "lua-" + "minetest-" + "node-" + "ocaml-" + "perl-" + "python-" + "r-" + "ruby-" + "rust-" + "sbcl-" + "texlive-")) + (name (package-name package))) + (or (assq-ref (package-properties package) 'upstream-name) + (let loop ((prefixes namespaces)) + (match prefixes + ('() name) + ((prefix rest ...) + (if (string-prefix? prefix name) + (substring name (string-length prefix)) + (loop (cdr prefixes))))))))) + (define (hidden-package p) "Return a \"hidden\" version of P--i.e., one that 'fold-packages' and thus, user interfaces, ignores." diff --git a/tests/packages.scm b/tests/packages.scm index a5819d8de3..f58c47817b 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -626,6 +626,10 @@ (define read-at (build-derivations %store (list drv)) (call-with-input-file output get-string-all))) +(test-equal "package-upstream-name*" + (package-upstream-name* (specification->package "guile-gcrypt")) + "gcrypt") + ;;; ;;; Source derivation with snippets. -- 2.37.4 --wmmVohns9Qrs/GFS Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0002-ui-Take-package-upstream-name-into-account-when-sear.patch" >From 5e0e8c0145a728d0ed49116596f06cc15e1e865d Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 9 Dec 2022 12:01:31 +0100 Subject: [PATCH v2 2/2] ui: Take package upstream name into account when searching. * guix/ui.scm (%package-metrics): Add PACKAGE-UPSTREAM-NAME*. --- guix/ui.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/guix/ui.scm b/guix/ui.scm index 45eccb7335..3bca3b1e40 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -1668,6 +1668,7 @@ (define %package-metrics ;; Metrics used to compute the "relevance score" of a package against a set ;; of regexps. `((,package-name . 4) + (,package-upstream-name* . 2) ;; Match against uncommon outputs. (,(lambda (package) -- 2.37.4 --wmmVohns9Qrs/GFS--