From patchwork Fri Dec 9 11:49:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lars-Dominik Braun X-Patchwork-Id: 45147 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9543327BBEB; Fri, 9 Dec 2022 11:51:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8D85327BBE9 for ; Fri, 9 Dec 2022 11:51:08 +0000 (GMT) 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-Disposition: inline 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 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.