From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YNt6NSYpB2B2SAAA0tVLHw (envelope-from ) for ; Tue, 19 Jan 2021 18:47:02 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8M4oMSYpB2AuHQAA1q6Kng (envelope-from ) for ; Tue, 19 Jan 2021 18:47:02 +0000 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 4D9E19402C2 for ; Tue, 19 Jan 2021 18:47:02 +0000 (UTC) Received: from localhost ([::1]:48200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1w1r-00016n-9K for larch@yhetil.org; Tue, 19 Jan 2021 13:47:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1vKM-0006YK-Sm for guix-patches@gnu.org; Tue, 19 Jan 2021 13:02:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l1vKL-0005EP-Ph for guix-patches@gnu.org; Tue, 19 Jan 2021 13:02:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l1vKL-0004Fu-Nz for guix-patches@gnu.org; Tue, 19 Jan 2021 13:02:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45893] [PATCH 0/2] DRAFT: Hint for options. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 19 Jan 2021 18:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45893 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 45893-submit@debbugs.gnu.org id=B45893.161107930515525 (code B ref 45893); Tue, 19 Jan 2021 18:02:01 +0000 Received: (at 45893) by debbugs.gnu.org; 19 Jan 2021 18:01:45 +0000 Received: from localhost ([127.0.0.1]:51615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1vK4-000421-Q4 for submit@debbugs.gnu.org; Tue, 19 Jan 2021 13:01:45 -0500 Received: from mail-qt1-f179.google.com ([209.85.160.179]:33573) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1vK1-0003ux-EF for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 13:01:43 -0500 Received: by mail-qt1-f179.google.com with SMTP id z6so7288971qtn.0 for <45893@debbugs.gnu.org>; Tue, 19 Jan 2021 10:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GYOCraHYz02A3yx5vMotQrplBibqvKVF4QHgPh/s/0I=; b=D/5p1Qtu7rxgGhrwLn8yqAdNguiiD/IgMAlB6uO1AGN0X4nywu8U6XPFEUV8ehqU22 U9aVRQDnWp9cGy9esf8x0Pmom7oDD0plTS3KA3j3c59R1iE5Xfoj/vXm41i9nji/HjXx rU2mIUH1t4oYOJcFBMsFmmRwFWRIbEaMLz1KwCgMZ++0kIoDihdBFQ+s0M3iIHGHeGiX cczwsRolDlygRj4+wJHqoAmqxnAD1ZnN1O0G9P58FYKKbxDT8ULAkH/ef9WNLRN000xv OzbKv8aZUUWLuYU8vwBP8/i5ysQ1+/TE79M6E/xpYeo2Wb4DG9dSXkLoZ2WzZSvm3Mji +dtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=GYOCraHYz02A3yx5vMotQrplBibqvKVF4QHgPh/s/0I=; b=UXg+9cO5l39HW/C5kQI7y4en27btP7tGWsqPIh0mR/lFYHka+Up1yID+AibU2o/n2A JogPS8Gc+1pev5JZ5s6pmByQDKnZTWaEHNJx+EmJZT57k6y8hyDIAH4gg/ce3lN7L7sX 7iu71ehVd2ZO2fotVfXaRce/ReBz9hTwjV3J5ICBY11m9w2Y/cDZifpE/OGdKd5g7bVe G54qzERTW4qjhjkQE1XPKSAYa0uzM60aLA7K/bnJgcj3FXFZS1+MWMqBBL8ZAHicuVNc tdQK095hqIL/m8FS2himnE3D027Jniv37xbDQB93VwWCnAd3UxZA3SYL52SqnXame8BH NUIA== X-Gm-Message-State: AOAM533cGWaYQDAGGJbY6+UyeaveN3k1HOCziYRUY7RcfzzQF+jAxJXc 29jFyqrNqkINzrdAaOalYmTrJ9441bO1MjDl+utuBrRoxb8= X-Google-Smtp-Source: ABdhPJzhxqPrjGyFgOTeRNI1L93GH1k7tepxVsDXYIkikK1QonB9IXy1MzJjF8KQZ/rm1U62TbuekwTBcVwdK4qYFy8= X-Received: by 2002:aed:3629:: with SMTP id e38mr5320293qtb.354.1611079295732; Tue, 19 Jan 2021 10:01:35 -0800 (PST) MIME-Version: 1.0 References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> In-Reply-To: <87a6t4hlom.fsf_-_@gnu.org> From: zimoun Date: Tue, 19 Jan 2021 19:01:24 +0100 Message-ID: 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: , Cc: 45893@debbugs.gnu.org Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.25 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b="D/5p1Qtu"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 4D9E19402C2 X-Spam-Score: -1.25 X-Migadu-Scanner: scn0.migadu.com X-TUID: IdYgwgIpgPO2 Hi, On Tue, 19 Jan 2021 at 18:38, Ludovic Court=C3=A8s wrote: > > zimoun skribis: > > > * guix/ui.scm (run-guix-command): Add command hint. > > [...] > > > + (fold (lambda (name res) > > + (if (string-null? res) > > + (string-append "@code{" name "}") > > + (string-append "@code{" name "}, " res))) > > + "" > > + (string-closest (symbol->string guess) command-names))) > > Hmm I thought =E2=80=98string-closest=E2=80=99 would return a single stri= ng, but > actually it returns a list of strings? > > You cannot append strings together like this as this can break i18n. Hum? But it is not (G_ "")... > The proper way would be to write: > > "Do you mean one of these: ~a?" > > but then, thinking about it, wouldn=E2=80=99t it be more natural to sugge= st a > single command rather than several? ...but the real question is this: one or several hints. Yeah, if we assume that it is about typo on the command line and the option names are different enough, which are both 2 reasonable assumptions, then it should always return one hint. Well, it depends if we consider the case where the typo is at the exact same distance as 2 different option names. > Also, it seems to me that there=E2=80=99s always at least one hit, is tha= t > correct? We should make sure that strings above a certain distance are > ignored, in which case there=E2=80=99s no hint to display. The hint reports all the options which are at the same minimum distance; whatever the minimum is. For instance "guix show --kikoo" would hint something. Instead, and including your remarks, maybe if the distance is greater than a threshold, then return an error as usual. Make more sense. > Next up is package names, right? :-) Hehe! I have tried... But it is not "doable" in practise... well, I find it too slow. The natural improvement is to cut down the levenhstein-distance by stopping if the score is greater than threshold. Well, I have not tried yet. :-) Thanks for the feedback and the comment. Cheers, simon