From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 11:37:47 2021 Received: (at submit) by debbugs.gnu.org; 15 Jan 2021 16:37:47 +0000 Received: from localhost ([127.0.0.1]:41549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0S6d-0006Hb-6h for submit@debbugs.gnu.org; Fri, 15 Jan 2021 11:37:47 -0500 Received: from lists.gnu.org ([209.51.188.17]:59300) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0S6a-0006HS-9O for submit@debbugs.gnu.org; Fri, 15 Jan 2021 11:37:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0S6Z-0004N6-DO for guix-patches@gnu.org; Fri, 15 Jan 2021 11:37:43 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:34617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0S6Y-0007Rq-1j for guix-patches@gnu.org; Fri, 15 Jan 2021 11:37:43 -0500 Received: by mail-wr1-x42a.google.com with SMTP id q18so9926533wrn.1 for ; Fri, 15 Jan 2021 08:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JMZOLS3ugLGM82Mz74arzHiwXl2cpsvWRqGHX6Ycw4Q=; b=DRuzG74eEpVXsMry+ys74AqR2Y93wg8QnsbXbxIiNHsNtWkfd2X8ApUGJfivp4OpHx 019GilUntVJYBAZTgdXMohzf0rXs5aw3Vcr95N9IAxZp1DIMC6PaEXM8am/MbNJd141B NLRSJVcEAuT7BpYrhDEkmxwEF63A9OMihwzwHwIO0Tn53BoL3cMoqtEBWD8xKZa/vDJD O+HAJJkUn7cjO4pccRWl1Qbrb0BEJpe+/Y0E6plcJzp97weG3/kbKKw6aWBVh94zt9Kh yBgOWAZSHGmIZyvKb3uUxQIyB/Xw7W/d6fkoUGmoALF5xXxwV8KXj6PsnRcwnFnIwNLJ xjYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JMZOLS3ugLGM82Mz74arzHiwXl2cpsvWRqGHX6Ycw4Q=; b=mD32XPVcibwcj136uSyaUccq1ZYLnfuu3zUJjmN3gURSaSm9uF2OYLUV7XhRTFU4fg RrD58vTI5zyorTzYN4vzSC4pvCZcY3YJ18E+DpLo39mn7z8oy4oIkLn3EUaGaoBzCCJl t9kENrElj20A/Zfs7Z23PHrjQK1gE7QTW3f59XxpXnkiIY9bZ6Z2s1dsIcKcnTHQpuRB fpdq8MAncVh1a4MeCqq1U+8iyHY3SK7YnEvEtNjhlwUuNlxK2i6PEecyYDW3XCtPyS9V dQYQDQt8VvRiwCYNwQN3NnLIl+bexv0IzxKW05Kml8BMitUkGrGI3B4ehEC7CGr064GA mrPQ== X-Gm-Message-State: AOAM533a00QH3eIao2L1Z8RHeEeKtFm1HdTUVKQvF1EZfqtuIya6xRnC NYyjsHF98o9THJugZwjIpU0yF/qnk6s= X-Google-Smtp-Source: ABdhPJwYC7MJ9XJieOMqDJ/kICFjdQ58cuzp0PeFFjqO/GUIxzSGkpPP3AqEw39qH3SeCBXDUomqXA== X-Received: by 2002:a5d:44c6:: with SMTP id z6mr14069124wrr.306.1610728660652; Fri, 15 Jan 2021 08:37:40 -0800 (PST) Received: from localhost.localdomain ([193.48.40.110]) by smtp.gmail.com with ESMTPSA id r20sm12535154wmh.15.2021.01.15.08.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 08:37:40 -0800 (PST) From: zimoun To: guix-patches@gnu.org Subject: [PATCH 0/2] DRAFT: Hint for options. Date: Fri, 15 Jan 2021 17:37:32 +0100 Message-Id: <20210115163732.53665-1-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi, The first patch uniformize. If this proposal is ok, then more Guix scripts have to be replaced; so the v2 could do that. The second patch is the interesting one. The naive implementation of Levenshtein distance by recursion is enough here when memoize is applied. However, the 'car' and 'cdr' is not in the Guix style, feedback welcome. Maybe abuse of fold, again feeback welcome. Well, the current result is: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix show --lead-paht hello hint: Do you mean `load-path'? guix show: error: lead-paht: unrecognized option --8<---------------cut here---------------end--------------->8--- All the best, simon zimoun (2): scripts: search, show: Replace 'args-fold*' by 'parse-command-line'. guix: scripts: Add hint for option typo. guix/scripts.scm | 58 +++++++++++++++++++++++++++++++++++++++++ guix/scripts/search.scm | 7 ++--- guix/scripts/show.scm | 8 ++---- 3 files changed, 62 insertions(+), 11 deletions(-) base-commit: c03875b0361f114634caeb54935fe37a9b7b05af -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 11:40:03 2021 Received: (at 45893) by debbugs.gnu.org; 15 Jan 2021 16:40:04 +0000 Received: from localhost ([127.0.0.1]:41563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0S8p-0006Lt-Ge for submit@debbugs.gnu.org; Fri, 15 Jan 2021 11:40:03 -0500 Received: from mail-wr1-f42.google.com ([209.85.221.42]:43645) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0S8n-0006LF-B9 for 45893@debbugs.gnu.org; Fri, 15 Jan 2021 11:40:02 -0500 Received: by mail-wr1-f42.google.com with SMTP id y17so9902094wrr.10 for <45893@debbugs.gnu.org>; Fri, 15 Jan 2021 08:40:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IIv1cBTgejQa5nRLYEn+7s0SCQVAxj2t8VtQnuda2TE=; b=Fc+m7k4jp8ZNADwPrAb08hphhkyU9Wi8aMd8VDyrBl05kVHoBxm9G5Xt3UsUggOYmx bMYoxjGjkQwXVlpMeCa9fZOc3pFR5lsFITxhahovVDkLGtF+WcqzaCDSOq9YA7koA4vm keAZHQwhsck7TdsTmA+4itJD4LOSRPED98PoW1uq0IrPqF8eu+9mUqlnmgxYV3ulHSgT 7kC5eV0PYco7cGTLS6QXKGhkzfMtPCHyZWT953XehUlikcm7HJ+fF2wJZLq3IgnJjJ+k kQKZdQRXpVlgg8tTAFjsbSJbQqDRMj5093u8pi2JF1Pm3D8Y4nd/Xpci1DkrZW2gd5GD cXfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IIv1cBTgejQa5nRLYEn+7s0SCQVAxj2t8VtQnuda2TE=; b=pQYNrqjQPG65y0xVgZHOw0puQMSfG57kTuuvAvKw8PILzfG4J9+jIzh/uDRfhuiAJQ 1JYPedzb7jZpEhDEygUcBpZRf+NOqi3rBHb5GE1Gd0znaVSpR9RwJitC99CfrHer176y AU4oGYqXeja5bKrpNCL5oVzXEy7EjTKl94ruJSg9D6bHIhwknYP7JMZrzoIrtLYkhWYF lbVb7r7cz2BD/91omFtAh1OsHJHTBZmbOWm9V34d+2zssrFezZl2Dy98nDcW1pkk4BRQ pNSR3ThDqI8CA6sUN5G6zXf3mlEZdDsk+9f5QE+DF/1ad2ufYPedgpOa64p+RFUMSBq7 X7lw== X-Gm-Message-State: AOAM532pJAZtSV/yG6iheakqrQ3RjtmL8arwFk0Z41HxSL23QII2jVKS jFLPfU9DG5Uwj3V6qhvYjg29QzMEk1Y= X-Google-Smtp-Source: ABdhPJxi2D/jnvsD/uE1cfvfzmkZFbo6w/Bs3s9x+A/rttMC+0wQttTcAz7hTVnViMo2LnQVD1K/9Q== X-Received: by 2002:a5d:457a:: with SMTP id a26mr14280569wrc.53.1610728795538; Fri, 15 Jan 2021 08:39:55 -0800 (PST) Received: from localhost.localdomain ([193.48.40.110]) by smtp.gmail.com with ESMTPSA id y63sm13744574wmd.21.2021.01.15.08.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 08:39:55 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: [PATCH 1/2] scripts: search, show: Replace 'args-fold*' by 'parse-command-line'. Date: Fri, 15 Jan 2021 17:39:52 +0100 Message-Id: <20210115163953.53721-1-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts/search.scm (define-command): Replace 'args-fold*' by 'parse-command-line'. * guix/scripts/show.scm (define-command): Replace 'args-fold*' by 'parse-command-line'. --- guix/scripts/search.scm | 7 ++----- guix/scripts/show.scm | 8 ++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/guix/scripts/search.scm b/guix/scripts/search.scm index 0c9e6af07b..1ac8089e6b 100644 --- a/guix/scripts/search.scm +++ b/guix/scripts/search.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -66,11 +67,7 @@ This is an alias for 'guix package -s'.\n")) result)) (define opts - (args-fold* args %options - (lambda (opt name arg . rest) - (leave (G_ "~A: unrecognized option~%") name)) - handle-argument - '())) + (parse-command-line args %options '())) (unless (assoc-ref opts 'query) (leave (G_ "missing arguments: no regular expressions to search for~%"))) diff --git a/guix/scripts/show.scm b/guix/scripts/show.scm index 535d03c1a6..6dfc082be3 100644 --- a/guix/scripts/show.scm +++ b/guix/scripts/show.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2019 Simon Tournier +;;; Copyright © 2019, 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -66,11 +66,7 @@ This is an alias for 'guix package --show='.\n")) result)) (define opts - (args-fold* args %options - (lambda (opt name arg . rest) - (leave (G_ "~A: unrecognized option~%") name)) - handle-argument - '())) + (parse-command-line args %options '())) (unless (assoc-ref opts 'query) (leave (G_ "missing arguments: no package to show~%"))) -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 11:40:06 2021 Received: (at 45893) by debbugs.gnu.org; 15 Jan 2021 16:40:06 +0000 Received: from localhost ([127.0.0.1]:41565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0S8r-0006M2-Sa for submit@debbugs.gnu.org; Fri, 15 Jan 2021 11:40:06 -0500 Received: from mail-wr1-f41.google.com ([209.85.221.41]:38631) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0S8n-0006LH-Pg for 45893@debbugs.gnu.org; Fri, 15 Jan 2021 11:40:03 -0500 Received: by mail-wr1-f41.google.com with SMTP id a9so6459216wrt.5 for <45893@debbugs.gnu.org>; Fri, 15 Jan 2021 08:40:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gRFuJZ81oxeGiRFlPuyyccU0Gx0IMa9uuI0KW5kyrSo=; b=hoO/GbObWc1gGds4Cm+xnqRlGpINPJT/CadHjAkasg1WtRgVvkNxRQSMEXGIDz30VS PciXeaZG0QvkLZ0SAzC6NHTZkzEwKMxDiU2YW6Tj4Yhi09wC0+aeTfBv5OxUrr7idOwD oHXR1iOJJZ21yFxUax4Zmou9rT7kfPVtGoiyudomVCdfo4QmWgiqC2rQDicQ1rnaOnnV b0bnU4CQczL56XLzlz7P6SqeWmV9cJ4V8yk+3Ju3HlITW8bRBIy0d4V1FHpT0mfyaPqW Mwj4t6hzxQ2CCjCrtUdtT5iBG+tAzInE54rv2u1oM4a6AmPbmMW6/5VpXAS9kmpV0USN YamA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gRFuJZ81oxeGiRFlPuyyccU0Gx0IMa9uuI0KW5kyrSo=; b=CJmnuoIKskX6MYCQIxSYn/S+2DRQyfw6GXv4Tasoxer6jKF0iobECCbXeGS9RJ5bBo sP109xHfPWnCSt0MolKMTZrAG5Dr26ekVGWtqYH5w54v8QY8Ye+FxWXKJ5xM49WVesXl b7RdGQKKMMWzphvrn9uc60y3/os0i7xIjFz7v4mcCaIx/Pn4mvqBkCMrqQWE1w8l/x8e hjJyF+FwAfIHRtF8+PhR3iCCeTCKyKEX0CsSl84v9qddHJighGgQsL3B+D2P2zqxWRGa MBxlLG/MnEElfMY2s4PpBhpCHFZJ3JU9bNLlhoF7B4l+EJ0BPKDcs2d2MLpZMeHYsKYE wGiw== X-Gm-Message-State: AOAM530e5KM9NKP4l2vTm6I/M1xDTjbjBQGrZl2MTWNutbS1FAOO/lpq EoeWdoCoRMhJ76oM2WLeso8ndFQB/1A= X-Google-Smtp-Source: ABdhPJwU1/kYPYzZU+yjebRRFKzmu52HrtJ0OU572x4XNPGlbAEQomgtJ2IjBENCLTn05EjMyeSn3w== X-Received: by 2002:adf:fdce:: with SMTP id i14mr14113212wrs.58.1610728796150; Fri, 15 Jan 2021 08:39:56 -0800 (PST) Received: from localhost.localdomain ([193.48.40.110]) by smtp.gmail.com with ESMTPSA id y63sm13744574wmd.21.2021.01.15.08.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 08:39:55 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: [PATCH 2/2] guix: scripts: Add hint for option typo. Date: Fri, 15 Jan 2021 17:39:53 +0100 Message-Id: <20210115163953.53721-2-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115163953.53721-1-zimon.toutoune@gmail.com> References: <20210115163953.53721-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts.scm (levenshtein-distance): New procedure. (options->long-names): New procedure. (option-hint): New procedure. --- guix/scripts.scm | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/guix/scripts.scm b/guix/scripts.scm index 34cba35401..f40eadfedd 100644 --- a/guix/scripts.scm +++ b/guix/scripts.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2015, 2016 Alex Kost ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Ricardo Wurmus +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ #:use-module ((guix profiles) #:select (%profile-directory)) #:autoload (guix describe) (current-profile-date) #:use-module (guix build syscalls) + #:use-module (guix memoization) #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (srfi srfi-37) @@ -112,6 +114,61 @@ procedure, but both the category and synopsis are meant to be read (parsed) by doc body ...))))) +(define (levenshtein-distance s1 s2) + "Compute the Levenshtein distance between two strings." + ;; Naive implemenation + (define loop + (memoize + (lambda (as bt) + (match as + ('() (length bt)) + (_ (match bt + ('() (length as)) + (_ + (let ((a (car as)) + (s (cdr as)) + (b (car bt)) + (t (cdr bt))) + (if (char=? a b) + (loop s t) + (1+ (min + (loop as t) + (loop s bt) + (loop s t)))))))))))) + + (let ((c1 (string->list s1)) + (c2 (string->list s2))) + (loop c1 c2))) + +(define (options->long-names options) + "Return long names from options." + (fold (lambda (name res) + (match name + ((? char?) res) + ((? string?) (cons name res)))) + '() + (fold append '() (map option-names options)))) + +(define (option-hint name options) + "Return the closest long-name from name based on Levenshtein distance." + (fold (lambda (name res) + (if (string-null? res) + name + (string-append name " or " res))) + "" + (cadr (fold (lambda (long-name res) + (let ((dist (levenshtein-distance name long-name))) + (match res + ((val lst) + (if (< dist val) + (list dist (list long-name)) + (if (= dist val) + (list dist (cons long-name lst)) + res))) + (_ (list dist (list long-name)))))) + '() + (options->long-names options))))) + (define (args-fold* args options unrecognized-option-proc operand-proc . seeds) "A wrapper on top of `args-fold' that does proper user-facing error reporting." @@ -149,6 +206,7 @@ parameter of 'args-fold'." ;; Actual parsing takes place here. (apply args-fold* args options (lambda (opt name arg . rest) + (display-hint (format #f (G_ "Do you mean @code{~a}?~%") (option-hint name options))) (leave (G_ "~A: unrecognized option~%") name)) argument-handler seeds)) -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 19:19:48 2021 Received: (at 45893) by debbugs.gnu.org; 16 Jan 2021 00:19:48 +0000 Received: from localhost ([127.0.0.1]:41984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZJj-0004nJ-Mf for submit@debbugs.gnu.org; Fri, 15 Jan 2021 19:19:47 -0500 Received: from mail-wr1-f41.google.com ([209.85.221.41]:44944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZJf-0004n3-OU for 45893@debbugs.gnu.org; Fri, 15 Jan 2021 19:19:46 -0500 Received: by mail-wr1-f41.google.com with SMTP id w5so10903372wrm.11 for <45893@debbugs.gnu.org>; Fri, 15 Jan 2021 16:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=fymLQoDo0SN4mKMadctCi2Z7iFoOUseAsQ0CZH0cZH4=; b=A1TQ994agtNNWjAFVne0UbtnH5/2HQWN2xp68WVMoLew6Ay4x73bkRyaCLwEKf59Mq LNzFWbE5I9mevwIeaUmHkkDgFU68ipgEoIUsk+X74tiotreBeywp5KRDz9zCaGlF/r70 NAK02Hr9Whrn+j2SI4D9OaJ+n5hyhsgP4dsEQg5Un28oLXcUV0mHl4v10Ml6d7nDKDo5 K2yES2S0uG2HUIieEpSrrIZbY8VZzyp0WvpIe1N/pbD1R+iTDPwoCY6Lx9DOeoPyIIF4 G5jqaSniNOCL98t7cuk2toJlvTUOUtzAkol4dgEjB+S2vO9PJTZNtZLLdg90TB8UGWCu btbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=fymLQoDo0SN4mKMadctCi2Z7iFoOUseAsQ0CZH0cZH4=; b=aWo13ecL7XDGpIouCQk2K5r5q2F1WDV5SpGscD6vf0tHKKCBvl3JOOC7m+UhX1O+RY st4A5We3zQUozYsVnR8ob3OFWtlJvXRnCMaXCFrU/mk0XDci0zbf4tnhQx4Lv9Z/wrnW qXQhCbe7+Tr1acGJodSIQ7RXOvsjvf56LkjVSBnkagBqiMXjR+6X2YZGzRK0Ik1GP4+v T+65LNWgXFQ3oN/F17rWkuMXTLS663vxDp2yNSC4zlmCbYQXVoAV3eTYfJ64VaUQgSD5 1T9luQfMVlwqRP3RBlOx0nxaNkYZbzLCBGtInzKzqUW7pheMiBnGXeUxXRLsAb+UwQmA GRnA== X-Gm-Message-State: AOAM532ZC4gDOvXJFeylM5Zwup4cwnsaXsfJBT5DAbhy/J7FpxWg+lZW lc3RjVeYE2ZoOC9O2biYq2I= X-Google-Smtp-Source: ABdhPJzj8D/Qorb73MknxFLhFue8EB1Y08Mf+CiKqIA+ExzXbLOeURja4PiJgX9hPSBqIU9CbWqlFA== X-Received: by 2002:adf:94c7:: with SMTP id 65mr15107269wrr.423.1610756377734; Fri, 15 Jan 2021 16:19:37 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id l7sm9488002wmg.41.2021.01.15.16.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 16:19:37 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: Re: [bug#45893] [PATCH v2 0/3] DRAFT: Hint command line typo References: <20210115163732.53665-1-zimon.toutoune@gmail.com> Date: Sat, 16 Jan 2021 01:09:41 +0100 In-Reply-To: <20210115163732.53665-1-zimon.toutoune@gmail.com> (zimoun's message of "Fri, 15 Jan 2021 17:37:32 +0100") Message-ID: <865z3xlp2y.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: ludo@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Here a v2 with some revamp. It looks like this: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix show --laod-pth hello hint: Do you mean `load-path'? guix show: error: laod-pth: unrecognized option $ ./pre-inst-env guix chow --laod-pth hello hint: Do you mean `show'? guix: chow: command not found Try `guix --help' for more information. $ ./pre-inst-env guix abcde hint: Do you mean `archive', `gc', `pack', `size'? guix: abcde: command not found Try `guix --help' for more information. $ ./pre-inst-env guix show --abcdefijk hello hint: Do you mean `help', `version', `load-path'? guix show: error: abcdefijk: unrecognized option --8<---------------cut here---------------end--------------->8--- First, the v2 remove of car, cdr etc in favor of =E2=80=99match=E2=80=99. = And, I do not know if my Emacs has the correct setup for indentation. Sorry for that. Second, the 3 added pieces are: 1. levenshtein-distance and string-closest in guix/utils.scm (patch 2) 2. option-hint in guix/scripts.scm (patch 2) 3. command-hint in guix/ui.scm (patch 3) #1 eases the reuses. Well, guix/utils.scm because I lacked imagination. The option-hint is only added in =E2=80=99parse-command-line=E2=80=99 and n= ot =E2=80=99args-fold*=E2=80=99 therefore currently this hint does not work fo= r all the subcommand. That=E2=80=99s the reason of the first patch that fixes for = =E2=80=9Cguix search=E2=80=9D and =E2=80=9Cguix show=E2=80=9D. If it is makes sense, I c= an easily replace all the =E2=80=99args-fold*=E2=80=99 by =E2=80=99parse-command-line=E2=80=99. = I am in favor of that for 2 reasons: a) one function to do one thing b) recommend this parse-command-line function for the new extensions Last, in this mood, a hint is added to the subcommand itself. Well, I am not sure it makes sense=E2=80=A6 Well, that=E2=80=99s just a proposal. Ah, I have not been inspired by the commit message. :-) All the best, simon zimoun (3): scripts: search, show: Replace 'args-fold*' by 'parse-command-line'. guix: scripts: Add hint for option typo. ui: Add command hint. guix/scripts.scm | 21 +++++++++++++++++ guix/scripts/search.scm | 7 ++---- guix/scripts/show.scm | 8 ++----- guix/ui.scm | 16 +++++++++++++ guix/utils.scm | 51 ++++++++++++++++++++++++++++++++++++++++- 5 files changed, 91 insertions(+), 12 deletions(-) base-commit: 884f320e7ceb35cb8472510e47fc5f1944675d82 -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 19:26:52 2021 Received: (at 45893) by debbugs.gnu.org; 16 Jan 2021 00:26:52 +0000 Received: from localhost ([127.0.0.1]:41993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZQZ-0004yT-RE for submit@debbugs.gnu.org; Fri, 15 Jan 2021 19:26:52 -0500 Received: from mail-wr1-f52.google.com ([209.85.221.52]:43190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZQX-0004yD-2G for 45893@debbugs.gnu.org; Fri, 15 Jan 2021 19:26:50 -0500 Received: by mail-wr1-f52.google.com with SMTP id y17so10924040wrr.10 for <45893@debbugs.gnu.org>; Fri, 15 Jan 2021 16:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IIv1cBTgejQa5nRLYEn+7s0SCQVAxj2t8VtQnuda2TE=; b=SJtrO/MS2KN/nVBvvvv1DOgLTmlw9e+xxLuwtYOv+s4hCyaPGAdY7Ybcv1v+nPJWOG zL2ZdfANR3du8Hs9tjC+A/+aoseRZ3SbPN/j3U/F0vHdsnbLCH02LB53ViRhmNBVHtfU rAAWs00FATG3xLUAhLUhxKz72K3uQpk3XbSrJ7FUhq45xts8sK1QJJuYcQLArDeqzedG 7ZxBaEdfcB9nR/sj7meDDI7Rwkt/NRC4/RErzkdDLpm/tr4zBuSmr2yFNJLMfds1knZD uSRFPgKY0hinjgp/uPFwStmV/YLYZpU+4iiOG7kjlRoWgrL8NgiU0MnkdaszhnEzmsmv dA+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IIv1cBTgejQa5nRLYEn+7s0SCQVAxj2t8VtQnuda2TE=; b=T+Fex72rvgLn5Td+A6N/OoTuaKZp+8ncnBv/gLGufldcSsKm7oJl0V7+gNz5BrrUhe +6qBzn9VKKY1O37P8iPYuz0dBAU510SGWxm6VAOaruQY4CqKzJutNRKm01z4/3FYDm20 XO2hpYJ9GovRThYaZ+IASqbg+Cv/jfP4sVAbwDwEiw+7ZjfvWMETkSiUb7HzJO6rqIfZ nPxds3wgcat+dRR5d4I1ZT8g2SyL826yuPwNqmXn/+A9qUuTsMY+T45pw3sV1o30II+B XAjbBHGcZd8DNo7TkE9XN/h/AROgNGPRuDI+AzQQ1rkC8/dICcOP7GGsXuVjQrZjXaaW ggLw== X-Gm-Message-State: AOAM533wjBaW6W0pVQReAh7jYzDLYWUZC58pVGy2Zjf/ljulOONrrwmB yx2X7TU9JS0ZgPbRtw7QYGe4R5vEQC4= X-Google-Smtp-Source: ABdhPJwlfzgRVd5xHljtXAlrwuq8EaEqSDYqqkRZpWUCm94HPoifYLZhtM4xWfgoxiyKf7rmQPXPMA== X-Received: by 2002:adf:a2ca:: with SMTP id t10mr15395569wra.370.1610756803167; Fri, 15 Jan 2021 16:26:43 -0800 (PST) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id u16sm4797475wrn.68.2021.01.15.16.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 16:26:42 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: [PATCH v2 1/3] scripts: search, show: Replace 'args-fold*' by 'parse-command-line'. Date: Sat, 16 Jan 2021 01:26:32 +0100 Message-Id: <20210116002634.10401-1-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <865z3xlp2y.fsf@gmail.com> References: <865z3xlp2y.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: ludo@gnu.org, zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts/search.scm (define-command): Replace 'args-fold*' by 'parse-command-line'. * guix/scripts/show.scm (define-command): Replace 'args-fold*' by 'parse-command-line'. --- guix/scripts/search.scm | 7 ++----- guix/scripts/show.scm | 8 ++------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/guix/scripts/search.scm b/guix/scripts/search.scm index 0c9e6af07b..1ac8089e6b 100644 --- a/guix/scripts/search.scm +++ b/guix/scripts/search.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019, 2020 Ludovic Courtès +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -66,11 +67,7 @@ This is an alias for 'guix package -s'.\n")) result)) (define opts - (args-fold* args %options - (lambda (opt name arg . rest) - (leave (G_ "~A: unrecognized option~%") name)) - handle-argument - '())) + (parse-command-line args %options '())) (unless (assoc-ref opts 'query) (leave (G_ "missing arguments: no regular expressions to search for~%"))) diff --git a/guix/scripts/show.scm b/guix/scripts/show.scm index 535d03c1a6..6dfc082be3 100644 --- a/guix/scripts/show.scm +++ b/guix/scripts/show.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2019 Simon Tournier +;;; Copyright © 2019, 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -66,11 +66,7 @@ This is an alias for 'guix package --show='.\n")) result)) (define opts - (args-fold* args %options - (lambda (opt name arg . rest) - (leave (G_ "~A: unrecognized option~%") name)) - handle-argument - '())) + (parse-command-line args %options '())) (unless (assoc-ref opts 'query) (leave (G_ "missing arguments: no package to show~%"))) -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 19:26:54 2021 Received: (at 45893) by debbugs.gnu.org; 16 Jan 2021 00:26:54 +0000 Received: from localhost ([127.0.0.1]:41996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZQc-0004yi-4K for submit@debbugs.gnu.org; Fri, 15 Jan 2021 19:26:54 -0500 Received: from mail-wr1-f42.google.com ([209.85.221.42]:44321) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZQa-0004yH-Ck for 45893@debbugs.gnu.org; Fri, 15 Jan 2021 19:26:52 -0500 Received: by mail-wr1-f42.google.com with SMTP id w5so10911797wrm.11 for <45893@debbugs.gnu.org>; Fri, 15 Jan 2021 16:26:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I7VQJBXPfHyF+i0beuahnjKJIC2NPAMgEmH0FrDiPa8=; b=pswU8U7qFsIBtc3LSaUAyLKwh3ZJxEqosjJqtNx2R4npsStlCf/wHuqbswDXjg4cX3 mgpBZsw3Lv0ZQFF63Ola0buidQWht0MZEBwaGAQ2psVsbQNI8dzuU5wATMotjeqdl7r2 60ovLRjurFPEmsCFalAJJ7zVSeG+1rpy72/LecYAyDOuel1ttu4ZdaYtxF24N+RnMp50 u/W+UvpcUwUap3bVM62BXxFCLoIm2JdwrzxQuHd/vzk9q8/zIZrCi53H3s9iws0m7u05 jbQl6gNuMBl1Sa8e5AC2/C6j8p/fBByH7++hHQiSLP0DS/0yVSiGCV0pxMCZVAUhloHq uCmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I7VQJBXPfHyF+i0beuahnjKJIC2NPAMgEmH0FrDiPa8=; b=plJHGPDyDSFd85gPBnMeW3F60OLapXIt3PzqrxLjUsK74AAPj4E6DKrdgOuR3j+wXc Ff9m6C1K2y93nR9pqVkv1oswXWFYErMiehHktHzlsC7Pg66M3/1cqGZw4oq9l5GhvGKb EiRm0Y4JdGFIOBUemXAsfkeIp+BS3QMSNBADc8il6dgqSvzCFy4o4xTVwFTC/AaXiqU6 XH5WVm0KrRB3AaTSuVutWpcbNlHdxBdw0DeJOHGD/pQfWQJpzaLzvUZgAtxUiHOMTSJr 5ME1n/lOAxi6Z1XydRS+Ix8FMzEwANJuqi4sVrjjUA9BWkp2+HqDLyvGbhmN94Lsa4Lw BOig== X-Gm-Message-State: AOAM533Qi+1/xkBiY7d1IU55fTIQXxb/iIGxmmM/r50Or/qB3XVmQwYc OqpfEfPYZ/cXAtPk7f8yEwLoyH82oCg= X-Google-Smtp-Source: ABdhPJxbzhUBh9Z1d6Uj1AUFBsHCuS89bpN2xfUPvj3rmxXzAIdx7DFUvo3bZfQucAZOoXYPriUw+g== X-Received: by 2002:adf:ab56:: with SMTP id r22mr15722154wrc.351.1610756806763; Fri, 15 Jan 2021 16:26:46 -0800 (PST) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id u16sm4797475wrn.68.2021.01.15.16.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 16:26:46 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: [PATCH v2 2/3] guix: scripts: Add hint for option typo. Date: Sat, 16 Jan 2021 01:26:33 +0100 Message-Id: <20210116002634.10401-2-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116002634.10401-1-zimon.toutoune@gmail.com> References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: ludo@gnu.org, zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/utils.scm (levenshtein-distance): New procedure. (string-closest): New procedure. * guix/scripts.scm (option-hint): New procedure. (parse-command-line): Add 'option-hint'. --- guix/scripts.scm | 21 ++++++++++++++++++++ guix/utils.scm | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/guix/scripts.scm b/guix/scripts.scm index 34cba35401..03d45c0888 100644 --- a/guix/scripts.scm +++ b/guix/scripts.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2015, 2016 Alex Kost ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Ricardo Wurmus +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -112,6 +113,23 @@ procedure, but both the category and synopsis are meant to be read (parsed) by doc body ...))))) +(define (option-hint guess options) + "Return the closest long-name from name based on Levenshtein distance." + (define (options->long-names options) + (fold (lambda (name res) + (match name + ((? char?) res) + ((? string?) (cons name res)))) + '() + (fold append '() (map option-names options)))) + + (fold (lambda (name res) + (if (string-null? res) + (string-append "@code{" name "}") + (string-append "@code{" name "}, " res))) + "" + (string-closest guess (options->long-names options)))) + (define (args-fold* args options unrecognized-option-proc operand-proc . seeds) "A wrapper on top of `args-fold' that does proper user-facing error reporting." @@ -149,6 +167,9 @@ parameter of 'args-fold'." ;; Actual parsing takes place here. (apply args-fold* args options (lambda (opt name arg . rest) + (display-hint + (format #f (G_ "Do you mean ~a?~%") + (option-hint name options))) (leave (G_ "~A: unrecognized option~%") name)) argument-handler seeds)) diff --git a/guix/utils.scm b/guix/utils.scm index f8b05e7e80..2a0fb28917 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2018, 2020 Marius Bakke ;;; Copyright © 2020 Efraim Flashner +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -114,7 +115,10 @@ call-with-decompressed-port compressed-output-port call-with-compressed-output-port - canonical-newline-port)) + canonical-newline-port + + levenshtein-distance + string-closest)) ;;; @@ -847,6 +851,51 @@ be determined." ;; raising an error would upset Geiser users #f)))))) + +;;; +;;; Hint based on Levenshtein distance +;;; + +(define (levenshtein-distance s1 s2) + "Compute the Levenshtein distance between two strings." + ;; Naive implemenation + (define loop + (memoize + (lambda (as bt) + (match as + ('() (length bt)) + ((a s ...) + (match bt + ('() (length as)) + ((b t ...) + (if (char=? a b) + (loop s t) + (1+ (min + (loop as t) + (loop s bt) + (loop s t))))))))))) + + (let ((c1 (string->list s1)) + (c2 (string->list s2))) + (loop c1 c2))) + +(define (string-closest trial tests) + "Return the list from TESTS the closest from the string TRIAL based on +Levenshtein distance." + (match (fold (lambda (test res) + (let ((dist (levenshtein-distance trial test))) + (match res + ((val lst) + (if (< dist val) + (list dist (list test)) + (if (= dist val) + (list dist (cons test lst)) + res))) + (_ (list dist (list test)))))) + '() + tests) + ((_ rest ...) (match rest ((head _ ...) head))))) + ;;; Local Variables: ;;; eval: (put 'call-with-progress-reporter 'scheme-indent-function 1) ;;; End: -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 15 19:26:57 2021 Received: (at 45893) by debbugs.gnu.org; 16 Jan 2021 00:26:57 +0000 Received: from localhost ([127.0.0.1]:41999 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZQf-0004yx-Hp for submit@debbugs.gnu.org; Fri, 15 Jan 2021 19:26:57 -0500 Received: from mail-wm1-f52.google.com ([209.85.128.52]:38910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZQc-0004yL-F4 for 45893@debbugs.gnu.org; Fri, 15 Jan 2021 19:26:55 -0500 Received: by mail-wm1-f52.google.com with SMTP id y187so9055504wmd.3 for <45893@debbugs.gnu.org>; Fri, 15 Jan 2021 16:26:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UI3+QFZZ1EzTucehI5O8SHkMfSiUn6sNHSzchGcPGmY=; b=sUDAKNwJFMtGx8EVQeKPP/DmuKP0QL10h4yntDWyHakoNTtRhJSYZz3HCKYGz0zJ6r UNn1XaBMJUpuESh2yiz3ZABSknia8F7hz475HJSNCb9LUCK/O2yXOynHTy6SzWvV6Uoj vybHIYvGdH++684I4WBBYhPk8pMKeVqm0ACB0hLzkoe9ebQP8dDuh1aXdOiedYmINoBH Y1vVUnDA9EStcWkqUKFneSKUDALZFV8qRq/+sA9fmLEDy5BjWLV+ld4ILhqT9UYFe4Yv kyVdf1zF1K2nmf+ToiYY2tDO+S3WBlBO4X6EdXMM+tIY/rMyWddhfMEWW/Plf/XGfs08 wdgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UI3+QFZZ1EzTucehI5O8SHkMfSiUn6sNHSzchGcPGmY=; b=eCWb92vPp1HgS5CLkp+siMZwBgxbdMZGSQRUyc1HGNIv35AIkOz4axYDzlMkA4UpND l64nnmT39WGnAAHjPNBUiHe5gByAUqrKtgRQ2CbcqC7K+yF1cHLBvnaxh6PLmfmVogTQ +SiPgQ+Ioa8nORazOe/EE14yRlTeL5o4UsB+NM4KHH/ZO3X5OFBRSiqI4kx38twWa7gP h2XufWBY6MQS3Fd1lQV6dnmUZIQkAZlaGgxuSJrDbqSu1BoiADm79qxwVQRpWYXTv0w7 6pRFLuQojki4s1OEurrJ8MA8ppXR/J56mhtnrVWKrtjVlhZWINxLA1Ig9klT3fCauBv1 PFIw== X-Gm-Message-State: AOAM531HqWvW72qiXn7qWwhlSuAxZkAcRHOZjiAQgY/R+Rz42Qt1IJEm 6wjRJxsD2kTJg3QuvEz2P3/OaWFyVGg= X-Google-Smtp-Source: ABdhPJw/AMcV2zT4HMzGCQQIUF9Lgh+q0G/WUUU5qeRVygDU3/2jGaKTDRoG7yw0DY3JCQz6Mvj1eA== X-Received: by 2002:a7b:c8cd:: with SMTP id f13mr10549131wml.56.1610756808791; Fri, 15 Jan 2021 16:26:48 -0800 (PST) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id u16sm4797475wrn.68.2021.01.15.16.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 16:26:48 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: [PATCH v2 3/3] ui: Add command hint. Date: Sat, 16 Jan 2021 01:26:34 +0100 Message-Id: <20210116002634.10401-3-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116002634.10401-1-zimon.toutoune@gmail.com> References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: ludo@gnu.org, zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/ui.scm (run-guix-command): Add command hint. --- guix/ui.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/guix/ui.scm b/guix/ui.scm index bd504c68da..43c2007594 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -2123,6 +2123,20 @@ Run COMMAND with ARGS.\n")) (define (run-guix-command command . args) "Run COMMAND with the given ARGS. Report an error when COMMAND is not found." + (define (command-hint guess commands) + (define command-names + (map (lambda (command) + (match (command-name command) + ((head tail ...) head))) + commands)) + + (fold (lambda (name res) + (if (string-null? res) + (string-append "@code{" name "}") + (string-append "@code{" name "}, " res))) + "" + (string-closest (symbol->string guess) command-names))) + (define module (catch 'misc-error (lambda () @@ -2139,6 +2153,8 @@ found." (load file) (resolve-interface `(guix extensions ,command))))) (lambda _ + (display-hint (format #f (G_ "Do you mean ~a?") + (command-hint command (commands)))) (format (current-error-port) (G_ "guix: ~a: command not found~%") command) (show-guix-usage)))))) -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 12:20:12 2021 Received: (at 45893) by debbugs.gnu.org; 19 Jan 2021 17:20:12 +0000 Received: from localhost ([127.0.0.1]:51483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1ufs-0001TG-3x for submit@debbugs.gnu.org; Tue, 19 Jan 2021 12:20:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1ufq-0001T0-5W for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 12:20:10 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56650) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1ufk-0006pJ-VN; Tue, 19 Jan 2021 12:20:04 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=47738 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l1ufi-0006vQ-0M; Tue, 19 Jan 2021 12:20:03 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. References: <20210115163732.53665-1-zimon.toutoune@gmail.com> <20210115163953.53721-1-zimon.toutoune@gmail.com> Date: Tue, 19 Jan 2021 18:20:00 +0100 In-Reply-To: <20210115163953.53721-1-zimon.toutoune@gmail.com> (zimoun's message of "Fri, 15 Jan 2021 17:39:52 +0100") Message-ID: <87im7shmin.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! zimoun skribis: > * guix/scripts/search.scm (define-command): Replace 'args-fold*' by > 'parse-command-line'. > * guix/scripts/show.scm (define-command): Replace 'args-fold*' by > 'parse-command-line'. [...] > - (args-fold* args %options > - (lambda (opt name arg . rest) > - (leave (G_ "~A: unrecognized option~%") name)) > - handle-argument > - '())) > + (parse-command-line args %options '())) In these two cases, you need to pass #:build-options? #f. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 12:31:44 2021 Received: (at 45893) by debbugs.gnu.org; 19 Jan 2021 17:31:44 +0000 Received: from localhost ([127.0.0.1]:51489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1ur2-0001m1-87 for submit@debbugs.gnu.org; Tue, 19 Jan 2021 12:31:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1ur0-0001lp-Kx for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 12:31:42 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56851) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1uqr-0008HF-Q5; Tue, 19 Jan 2021 12:31:34 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=47960 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l1uql-00049Z-Am; Tue, 19 Jan 2021 12:31:29 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-2-zimon.toutoune@gmail.com> Date: Tue, 19 Jan 2021 18:31:25 +0100 In-Reply-To: <20210116002634.10401-2-zimon.toutoune@gmail.com> (zimoun's message of "Sat, 16 Jan 2021 01:26:33 +0100") Message-ID: <87eeighlzm.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) zimoun skribis: > * guix/utils.scm (levenshtein-distance): New procedure. > (string-closest): New procedure. > * guix/scripts.scm (option-hint): New procedure. > (parse-command-line): Add 'option-hint'. Yay! > +(define (option-hint guess options) > + "Return the closest long-name from name based on Levenshtein distance." > + (define (options->long-names options) > + (fold (lambda (name res) > + (match name > + ((? char?) res) > + ((? string?) (cons name res)))) > + '() > + (fold append '() (map option-names options)))) I think this can be simplified a bit: options->long-names =3D (filter string? (append-map option-names options)) > + (fold (lambda (name res) > + (if (string-null? res) > + (string-append "@code{" name "}") > + (string-append "@code{" name "}, " res))) > + "" > + (string-closest guess (options->long-names options)))) > + > (define (args-fold* args options unrecognized-option-proc operand-proc .= seeds) > "A wrapper on top of `args-fold' that does proper user-facing error > reporting." > @@ -149,6 +167,9 @@ parameter of 'args-fold'." > ;; Actual parsing takes place here. > (apply args-fold* args options > (lambda (opt name arg . rest) > + (display-hint > + (format #f (G_ "Do you mean ~a?~%") > + (option-hint name options))) > (leave (G_ "~A: unrecognized option~%") name)) > argument-handler > seeds)) [...] > +(define (levenshtein-distance s1 s2) > + "Compute the Levenshtein distance between two strings." Maybe call it =E2=80=98string-distance=E2=80=99? > + ;; Naive implemenation > + (define loop > + (memoize > + (lambda (as bt) Instead of (memoize (lambda =E2=80=A6)), you can write: (mlambda (str1 str2) =E2=80=A6) > + (match as > + ('() (length bt)) The pattern for the empty list is (), not '(). How about making this addition to (guix utils) a commit of its own, and to add a small test in tests/utils.scm? > +(define (string-closest trial tests) > + "Return the list from TESTS the closest from the string TRIAL based on > +Levenshtein distance." Maybe something like: =E2=80=9CReturn the string from TESTS that is the clo= sest from TRIAL, according to 'string-distance'.=E2=80=9D > + (match (fold (lambda (test res) > + (let ((dist (levenshtein-distance trial test))) > + (match res > + ((val lst) > + (if (< dist val) > + (list dist (list test)) > + (if (=3D dist val) > + (list dist (cons test lst)) > + res))) > + (_ (list dist (list test)))))) > + '() > + tests) > + ((_ rest ...) (match rest ((head _ ...) head))))) You can simplify this a bit by using =E2=80=98fold2=E2=80=99, which allows = you to pass two seeds instead of one: (fold2 (lambda (test closest shortest-distance) =E2=80=A6) "" +inf.0 tests) It returns two values and the first one is the string. Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 12:36:11 2021 Received: (at 45893) by debbugs.gnu.org; 19 Jan 2021 17:36:11 +0000 Received: from localhost ([127.0.0.1]:51493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1uvK-0001su-T0 for submit@debbugs.gnu.org; Tue, 19 Jan 2021 12:36:11 -0500 Received: from mail-qt1-f178.google.com ([209.85.160.178]:38336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1uvH-0001sE-1T for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 12:36:09 -0500 Received: by mail-qt1-f178.google.com with SMTP id c12so8734601qtv.5 for <45893@debbugs.gnu.org>; Tue, 19 Jan 2021 09:36:06 -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=EyCPcjHnhA4lQXmmbRuxE+kTJU/6Q2DGd35NAiBnbWs=; b=nuwUMK+eQBEXfQaw9eCRFOoZHFcsPr4FsFo2PmSpNTPVQYm6kr9DG4w+W9zr4thCoc KHMM0QmVWduX2jU02GelXrC2a40HL/s5C6yjXh1TdEQunO2FbMkykKzvBxXb09mjOQcP CXpkFEuT+nISWQL4KufxG1aejsu+81voquoiZezswziH4Ok3EFqdvXlaqW8zJ1gXnZek hgj/b9zDDeuDQXGfnrDfuyhUVwzGjPs17e5Jqa8H09iPHo/7vowgWtS4awNg221MBxre OVScrKAlLtN97i/WD/L+VUp3x6+DD87otPoKWe3LakP8QmtUiCvmjPMFNkFr4JPaB0Un RJ6A== 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=EyCPcjHnhA4lQXmmbRuxE+kTJU/6Q2DGd35NAiBnbWs=; b=e2Px0I7uLPKERVj57XYY/YmM0vD6Ljw50jme/5NZeM3tNtYlWEEnRTBEgNesrnUKWv EriiP0n/PkJIp4iGL9HfjvK2VCBQVTBHVT2gHZ7cCALxt7yN87GqcWy7GqvrPpvYoAlK aF1B5T8XQfnTVfQzoirTzb7dDi2w3OODN5OGJNfTXHV8OzMux5Qlkm+gxWS3Brtg8bMd U9NEtgh4KEnbfmpQvMw23G07iCg6/KRUG+fdRWvaWkh4mV29t5iEfx2fc7uMe69ffOlJ DZHATkoigKDV53Sia7Z7Xpy7R4fdMTtgNmWyDyycUVHH9W/XutX0pFVN9BHHxqlzWruk ZDmw== X-Gm-Message-State: AOAM531DoRRpI6EJU6wlj7sSYoYA3J2BjE+ZJt70pmddfXNFPYOsmBgd 5tGb6TuEmyZyoagY/SfgfZBWzYq2tGIA6cbyDc4= X-Google-Smtp-Source: ABdhPJyLqbdREaK3OqL7r7Tz86E4lGvcey9xR5Ci0u0azv2TTrpjfANukZeTLFvr3e/7PMKqdjPirjqG0z6NAgLY5RA= X-Received: by 2002:ac8:57c1:: with SMTP id w1mr5263075qta.313.1611077760939; Tue, 19 Jan 2021 09:36:00 -0800 (PST) MIME-Version: 1.0 References: <20210115163732.53665-1-zimon.toutoune@gmail.com> <20210115163953.53721-1-zimon.toutoune@gmail.com> <87im7shmin.fsf_-_@gnu.org> In-Reply-To: <87im7shmin.fsf_-_@gnu.org> From: zimoun Date: Tue, 19 Jan 2021 18:35:49 +0100 Message-ID: Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo, On Tue, 19 Jan 2021 at 18:20, Ludovic Court=C3=A8s wrote: > zimoun skribis: > > > * guix/scripts/search.scm (define-command): Replace 'args-fold*' by > > 'parse-command-line'. > > * guix/scripts/show.scm (define-command): Replace 'args-fold*' by > > 'parse-command-line'. > > [...] > > > - (args-fold* args %options > > - (lambda (opt name arg . rest) > > - (leave (G_ "~A: unrecognized option~%") name)) > > - handle-argument > > - '())) > > + (parse-command-line args %options '())) > > In these two cases, you need to pass #:build-options? #f. Ok. One question is: do we replace all the 'args-fold*' by 'parse-command-line' (with the correct arguments)? If yes, the proposal works. Otherwise, the computation of the hint should be moved to elsewhere. But where to avoid to duplicate code (replacing args-fld* by parse-command-line in all guix/scripts/ fixes the issue). Note that the "issue" is to handle the error. For example, if one moves "option-hint" to "args-fold*" then the hint would not work for all the commands. What is your suggestion? All the best, simon From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 12:38:20 2021 Received: (at 45893) by debbugs.gnu.org; 19 Jan 2021 17:38:20 +0000 Received: from localhost ([127.0.0.1]:51497 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1uxQ-0001vv-9h for submit@debbugs.gnu.org; Tue, 19 Jan 2021 12:38:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1uxO-0001vj-Li for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 12:38:18 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56985) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1uxJ-0000op-Er; Tue, 19 Jan 2021 12:38:13 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=48090 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l1ux9-0008KX-E8; Tue, 19 Jan 2021 12:38:12 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> Date: Tue, 19 Jan 2021 18:38:01 +0100 In-Reply-To: <20210116002634.10401-3-zimon.toutoune@gmail.com> (zimoun's message of "Sat, 16 Jan 2021 01:26:34 +0100") Message-ID: <87a6t4hlom.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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 string= , but actually it returns a list of strings? You cannot append strings together like this as this can break i18n. 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 suggest= a single command rather than several? Also, it seems to me that there=E2=80=99s always at least one hit, is that correct? We should make sure that strings above a certain distance are ignored, in which case there=E2=80=99s no hint to display. Thanks! Next up is package names, right? :-) Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 13:01:45 2021 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: Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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 From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 16:28:30 2021 Received: (at 45893) by debbugs.gnu.org; 19 Jan 2021 21:28:30 +0000 Received: from localhost ([127.0.0.1]:51938 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1yY9-0005nS-Qy for submit@debbugs.gnu.org; Tue, 19 Jan 2021 16:28:30 -0500 Received: from mail-wr1-f52.google.com ([209.85.221.52]:43423) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1yY8-0005nF-KR for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 16:28:28 -0500 Received: by mail-wr1-f52.google.com with SMTP id y17so21138453wrr.10 for <45893@debbugs.gnu.org>; Tue, 19 Jan 2021 13:28:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ej7JNNEa8ZWZW0jj2FCP8t+HXFmgK8Ieh9JBsR0FZgM=; b=J/IOY/vIYKdSUHqmOMNoKkN6e+ONDT9+G6XqS1NP/yMrupTHbdiX7JqwUzjBn/zDKy uqFkdQHHkzxdvjxm+h8o2lFFrVbHPrx56dMQTEt5a7TLfDwq1vEywR4gBX/aLp0AGlY0 DoggW6mORbKutJpJZ7etbusNoNdmVgYTza+VNI+qrc3ZSHosEQHrgL3tw9G9v/ATZqwk I8PMMjZPRKcA7+CnX0kx2uThH0DnLLqeJ6vFyWNo8mML24nQiIsh0OP7oHCKH+FprTcQ rJu7GHUquZ1bfBT14UfJwqehyZyQAYHP5qE5SXzjLuwEkZ/TYY2VwNJCBtMhj2I5sTB/ D/SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ej7JNNEa8ZWZW0jj2FCP8t+HXFmgK8Ieh9JBsR0FZgM=; b=Zi+Tz41PFpJe9ldeMxffn4PFxf1ciQT4t/t7pp8Mf2rB+H5CfvFmgDQxPUb4HiJjmx D/+LO78uK2iL0o8YyD/xLgqPa68bNi5evcC/xaUdFmbkxOKJnruCG8bW4Rld6/kYlI5I /FS2PRWdn6bvDdIsOuuX/rUBEDhw3FPcWhBetxYt2BBFjQrqivQxh/AuVooeFCXSMyhs oivE9S2jWSOb1D7ZmF73NNLXq/p/d7d7L6EwWn8toI3nkPJK41gY6oducfCvOnibjF22 shYnF7tVQFtXdrD/uPww3NAVROuqhUMQT3h9mNDn0pa88xNDuElyT8L2ATrjvIXOFw5C HELg== X-Gm-Message-State: AOAM532ddK3X1CWOjqT7E2vwxVvj6BOEr5W2KHLknOb+ScK907wu7OxI Ccs69q86r2r/mPkglV5m7qsZfdC8XLI= X-Google-Smtp-Source: ABdhPJzlh3O/nikghLiZcBUQBO8PDO2wt9QoVMbAqNiU8NbTFlg8XFFjn2rLCDFZYP6y4SHWv7OGuA== X-Received: by 2002:a5d:40ce:: with SMTP id b14mr6055610wrq.350.1611091703186; Tue, 19 Jan 2021 13:28:23 -0800 (PST) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id w8sm37844239wrl.91.2021.01.19.13.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 13:28:22 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: [PATCH v3 3/3] ui: Add hint for command typo. Date: Tue, 19 Jan 2021 22:28:10 +0100 Message-Id: <20210119212810.20681-3-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210119212810.20681-1-zimon.toutoune@gmail.com> References: <20210119212810.20681-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/ui.scm (command-hint): New variable * guix/ui.scm (run-guix-command): Use it. --- guix/ui.scm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/guix/ui.scm b/guix/ui.scm index bd504c68da..895c3a721f 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -2123,6 +2123,14 @@ Run COMMAND with ARGS.\n")) (define (run-guix-command command . args) "Run COMMAND with the given ARGS. Report an error when COMMAND is not found." + (define (command-hint guess commands) + (define command-names + (map (lambda (command) + (match (command-name command) + ((head tail ...) head))) + commands)) + (string-closest (symbol->string guess) command-names #:threshold 3)) + (define module (catch 'misc-error (lambda () @@ -2139,9 +2147,12 @@ found." (load file) (resolve-interface `(guix extensions ,command))))) (lambda _ - (format (current-error-port) - (G_ "guix: ~a: command not found~%") command) - (show-guix-usage)))))) + (let ((hint (command-hint command (commands)))) + (when hint + (display-hint (format #f (G_ "Do you mean @code{~a}?") hint))) + (format (current-error-port) + (G_ "guix: ~a: command not found~%") command) + (show-guix-usage))))))) (let ((command-main (module-ref module (symbol-append 'guix- command)))) -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 16:28:33 2021 Received: (at 45893) by debbugs.gnu.org; 19 Jan 2021 21:28:34 +0000 Received: from localhost ([127.0.0.1]:51940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1yYD-0005nn-Ip for submit@debbugs.gnu.org; Tue, 19 Jan 2021 16:28:33 -0500 Received: from mail-wr1-f50.google.com ([209.85.221.50]:37877) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1yY9-0005nG-2A for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 16:28:30 -0500 Received: by mail-wr1-f50.google.com with SMTP id v15so17486063wrx.4 for <45893@debbugs.gnu.org>; Tue, 19 Jan 2021 13:28:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B9yOI7weg3PgvZxylgSXhQT3lanNe9Wi7hAgSbLA+XA=; b=DQFZ5Mqel+4OYM2KF7bV7jvIP99jXLT92Db6igPqXuPk5miBg50Jvv1an2G51TdEqy o6AeWVYDw/R64aXVyB0obL7gXmcBCtpHPR773qFCu36W4ZKuRFsIjofjmZlUOExm1k9U sPNDkUhRVJbf6SpPn7qAR+bR1O+jVxnO0+//GwuRH1z6bsn6MUAwEcZp+b60ghn+kMKt 2fSZbta9LI/bHAga3JXr3f9eXy7FpVp5JvSzwQpzlU/Jsrv20Stob6gX4+Be1I8ev4z1 6eOHDc4LV9CIqN3fqs7mWsqsv8ucS36v6h64AZWpaKsQifpaKsEsPPPD0sl868GqvLTZ XrAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B9yOI7weg3PgvZxylgSXhQT3lanNe9Wi7hAgSbLA+XA=; b=MQ2XzQ8p+CJKovV53AXODsaASM+VfXnoYG0mtA0IAD8RB5IxvgRPUs2gaM4K6c7uN+ rMxBzkqp1U+gJIGMe7zmbo7PZ6pj0jMWvCobrZ3mDiotSi0xXTSw5JNGYcOq4y3RmlcH MthsYlkBzuKJhivSH30hIFx0sWrm34yGEh8wvl9oOLkevBVeHvyG2fUStzRvaPWLeRju wfl66ttlzpsyuP0hEnNbUVpyXddPNK9JuavKZw121nio/Xyf+s00HHLzmi3c3wyde7Oi K2ckV8kfqkrTCKDZMYQaynanfPTMpXt2jPchmi0CCiHQEKZVcE3qEm1N95TK7H497aeY raxw== X-Gm-Message-State: AOAM531ulfIOUAVWj+tzzzDW2bBQdkZJrRiuIahsC3I/m1BsVheT92xH WdTjK/eLff3QPrQH2+5903k0Q4gcCbg= X-Google-Smtp-Source: ABdhPJzu7fld2IXcoH9Qz/bUDSSRb5RBnvlvOTrjjY5mz3mbMtsQDmXy+OjvUy5VvTv3haqHPkc1kA== X-Received: by 2002:a5d:674b:: with SMTP id l11mr6365680wrw.247.1611091702414; Tue, 19 Jan 2021 13:28:22 -0800 (PST) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id w8sm37844239wrl.91.2021.01.19.13.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 13:28:22 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: [PATCH v3 2/3] guix: scripts: Add hint for option typo. Date: Tue, 19 Jan 2021 22:28:09 +0100 Message-Id: <20210119212810.20681-2-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210119212810.20681-1-zimon.toutoune@gmail.com> References: <20210119212810.20681-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/scripts.scm (option-hint): New procedure. (parse-command-line): Add 'option-hint'. --- guix/scripts.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/guix/scripts.scm b/guix/scripts.scm index 34cba35401..e997edbb6d 100644 --- a/guix/scripts.scm +++ b/guix/scripts.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2015, 2016 Alex Kost ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Ricardo Wurmus +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -112,6 +113,13 @@ procedure, but both the category and synopsis are meant to be read (parsed) by doc body ...))))) +(define (option-hint guess options) + "Return the closest long-name OPTIONS from GUESS, +according to'string-distance'." + (define (options->long-names options) + (filter string? (append-map option-names options))) + (string-closest guess (options->long-names options) #:threshold 3)) + (define (args-fold* args options unrecognized-option-proc operand-proc . seeds) "A wrapper on top of `args-fold' that does proper user-facing error reporting." @@ -149,7 +157,11 @@ parameter of 'args-fold'." ;; Actual parsing takes place here. (apply args-fold* args options (lambda (opt name arg . rest) - (leave (G_ "~A: unrecognized option~%") name)) + (let ((hint (option-hint name options))) + (when hint + (display-hint + (format #f (G_ "Do you mean @code{~a}?~%") hint))) + (leave (G_ "~A: unrecognized option~%") name))) argument-handler seeds)) -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 16:28:34 2021 Received: (at 45893) by debbugs.gnu.org; 19 Jan 2021 21:28:34 +0000 Received: from localhost ([127.0.0.1]:51942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1yYD-0005nr-TB for submit@debbugs.gnu.org; Tue, 19 Jan 2021 16:28:34 -0500 Received: from mail-wr1-f52.google.com ([209.85.221.52]:44971) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l1yY7-0005nB-0P for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 16:28:30 -0500 Received: by mail-wr1-f52.google.com with SMTP id w5so21112716wrm.11 for <45893@debbugs.gnu.org>; Tue, 19 Jan 2021 13:28:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bvEA+JM8FF2+1rpkio+/nDOgmiys3kqOHjH7bNLroAQ=; b=cYoDO/oRpe2oMtspohAX5dTZkCg4rVGZBtygXrfvNs3PxNGtXukelN130Si1TENLhi 1SP2HZPM2YLTZYscMxD5ff+E/MEtuJ8dILvn81ZlosxwHxaz6ycS9VxVnoMbnxKqmyEz ZWa2UqkLnT8eHdvNYDjCWXCorZw3e7larkm1Y8jfG1dO3wg9je0yyhc9MP3G6fEpDS/E pLVqbnYAom3uaZr3p55Vm8K2RYqaWbKncGk+06JUw3H/vKRQwprl6PhUytd46ICZI26B vtD/h4WBL8OgTSYqe109xvNtTLZRuyByD/5TNuh6Cn1ZAcDtxxtT1AAwauWcqE+N/Qd5 P3NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bvEA+JM8FF2+1rpkio+/nDOgmiys3kqOHjH7bNLroAQ=; b=moKxQfiaTdNWU+ctVB/A9vKHOh+aqTee08zTv2J04JaLT3Q53FibtIquJj7t2psB5Y vgrpYXdgRWEFMBBIMr78LdNitGzjCy67TOQaUsM/ZMggMmdq7K7hD0AzN7Gbs7lZWBEk dX6wT5HQlA08DLj1YAEKJHiVf2DBGYsPRcqqKA292xjIjL0+tOcgefjzi+A9PhTF8ENN EApPmdwo3WXg1+OhfC2tHyRS7v/IO+XADu44QYJ6o2baVxiO4bFCwpZS7iS2hteZnPwp u6FatNw+hlaPnjdlGr2DtK2vFetiMhyrZeNIBei90VkuNMm3Jc78MCPHJEYGLdt2WkFM 2U+w== X-Gm-Message-State: AOAM533SzTOEJaWk0y0Ma8CK4qGroiSkylEKRcTUUJ4eK5clx5JIuXAI R588OwhO0JJmpCqvHrjfE5VbFYs2em8= X-Google-Smtp-Source: ABdhPJzoa4c/EdwJ9/+NcpmWRVvVqXqGOvlfAvN73H7wgWG/Clp75nxvG8W6SNPsEtlMfB0arrzsFQ== X-Received: by 2002:adf:d0d0:: with SMTP id z16mr6212835wrh.209.1611091700987; Tue, 19 Jan 2021 13:28:20 -0800 (PST) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id w8sm37844239wrl.91.2021.01.19.13.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 13:28:20 -0800 (PST) From: zimoun To: 45893@debbugs.gnu.org Subject: [PATCH v3 1/3] utils: Add string distance. Date: Tue, 19 Jan 2021 22:28:08 +0100 Message-Id: <20210119212810.20681-1-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * guix/utils.scm (string-distance): New procedure. (string-closest): New procedure. * tests/utils.scm: Test it. --- guix/utils.scm | 47 ++++++++++++++++++++++++++++++++++++++++++++++- tests/utils.scm | 18 ++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/guix/utils.scm b/guix/utils.scm index f8b05e7e80..dc2259ef8c 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2018, 2020 Marius Bakke ;;; Copyright © 2020 Efraim Flashner +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,6 +38,7 @@ #:use-module (guix memoization) #:use-module ((guix build utils) #:select (dump-port mkdir-p delete-file-recursively)) #:use-module ((guix build syscalls) #:select (mkdtemp! fdatasync)) + #:use-module ((guix combinators) #:select (fold2)) #:use-module (guix diagnostics) ;, &error-location, etc. #:use-module (ice-9 format) #:use-module (ice-9 regex) @@ -114,7 +116,10 @@ call-with-decompressed-port compressed-output-port call-with-compressed-output-port - canonical-newline-port)) + canonical-newline-port + + string-distance + string-closest)) ;;; @@ -847,6 +852,46 @@ be determined." ;; raising an error would upset Geiser users #f)))))) + +;;; +;;; String comparison. +;;; + +(define (string-distance s1 s2) + "Compute the Levenshtein distance between two strings." + ;; Naive implemenation + (define loop + (mlambda (as bt) + (match as + (() (length bt)) + ((a s ...) + (match bt + (() (length as)) + ((b t ...) + (if (char=? a b) + (loop s t) + (1+ (min + (loop as t) + (loop s bt) + (loop s t)))))))))) + + (let ((c1 (string->list s1)) + (c2 (string->list s2))) + (loop c1 c2))) + +(define* (string-closest trial tests #:key (threshold 3)) + "Return the string from TESTS that is the closest from the TRIAL, +according to 'string-distance'. If the TESTS are too far from TRIAL, +according to THRESHOLD, then #f is returned." + (identity ;discard second return value + (fold2 (lambda (test closest minimal) + (let ((dist (string-distance trial test))) + (if (and (< dist minimal) (< dist threshold)) + (values test dist) + (values closest minimal)))) + #f +inf.0 + tests))) + ;;; Local Variables: ;;; eval: (put 'call-with-progress-reporter 'scheme-indent-function 1) ;;; End: diff --git a/tests/utils.scm b/tests/utils.scm index 9bce446d98..40eaf65bbc 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2014 Eric Bavier ;;; Copyright © 2016 Mathieu Lirzin +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -265,6 +266,23 @@ skip these tests." string-reverse) (call-with-input-file temp-file get-string-all))) +(test-equal "string-distance" + '(0 1 1 5 5) + (list + (string-distance "hello" "hello") + (string-distance "hello" "helo") + (string-distance "helo" "hello") + (string-distance "" "hello") + (string-distance "hello" ""))) + +(test-equal "string-closest" + '("hello" "hello" "helo" #f) + (list + (string-closest "hello" '("hello")) + (string-closest "hello" '("helo" "hello" "halo")) + (string-closest "hello" '("kikoo" "helo" "hihihi" "halo")) + (string-closest "hello" '("aaaaa" "12345" "hellohello" "h")))) + (test-end) (false-if-exception (delete-file temp-file)) base-commit: 884f320e7ceb35cb8472510e47fc5f1944675d82 prerequisite-patch-id: 07abf72be0f4db9fbc19cb719d87bc1c69e8479d -- 2.29.2 From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 19:05:52 2021 Received: (at 45893) by debbugs.gnu.org; 20 Jan 2021 00:05:52 +0000 Received: from localhost ([127.0.0.1]:52147 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l210S-0005dv-60 for submit@debbugs.gnu.org; Tue, 19 Jan 2021 19:05:52 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:35787) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l210M-0005de-SR for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 19:05:50 -0500 Received: by mail-wm1-f49.google.com with SMTP id e15so1306205wme.0 for <45893@debbugs.gnu.org>; Tue, 19 Jan 2021 16:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=T1YGZd1jiB1/keX2Fr/77gsDVsoLQrjfq1ToSNegR3Y=; b=NFiCIZO46jpG4M1ZkUbahe5UAygHYmu2bRRGgPMX4qvinKnoJYdXqgvm7SyUTfUdb4 vINkxEZdYWVjq5JkLznoVFCFhV2g9t/ngGV864WFc2+iS7P+GSUGoTT1fpwMiFv6zYW5 cOoBQCYhK5QmZ+mGusPgXdTUwtT8hNinA5Ggr+lo4TsYe24Vu35Ym2dU/ySsULBykIF7 8XyfMLdC0nBpbPJ9MTfz1Hz2E6oKB/B6YmMUeh+976W6Lgtm82N1PVD8eTnDdxQxD06u fCWSqAissq7nd0rTrXSlVeJF2f5IF6d4TkVVHUykLxgE9uUGrbLqE8OBP8Xa6mm+fpTo t95A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=T1YGZd1jiB1/keX2Fr/77gsDVsoLQrjfq1ToSNegR3Y=; b=EdRuOF0cfs3NKtrobsIXy2TKG45qWSY8uJcAlxWHY7j1AZFvMOVn85a4pr6Y1crwZE CD84cdrmqrvroSariNvI+CbUmpfWYJEyWgxEDIAKsV6ejnBI+qzrTrAaI52kf34HqEyS XR4H5wu4zKO8SN6IGc4U2Py6NLbtSxIBKH6T8Is0UyJSX0kggpCuft0N7sa6lnEDpode dEc5WdKJV/lXl8kyztkYEVRnwMlyIvktc61QVhGVJkUC2jSImH0W2WkrCw/MhcDPkVVj /UxGghIR6+nujceTWN75sqx8hwv8uZpAqpMqUIo2AetPtGUqsFZG2hVaTqvD9NPG+u/Q XCeA== X-Gm-Message-State: AOAM532Ao2eDe/VGU1mkPesbI310HRq98rfVc16MMGcMkRkACIFteKLG brIhSB5zSKM+TySNMZ67cNKZSKy+sjQ= X-Google-Smtp-Source: ABdhPJw5rsleBSPpK6cF5tbts3OTjvbds1DAVW0HjVqRlduELOhCER5oCP6qJhk+P2l0EZqR8SiMOA== X-Received: by 2002:a7b:cc0a:: with SMTP id f10mr1718664wmh.6.1611101140715; Tue, 19 Jan 2021 16:05:40 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id q7sm520557wrx.18.2021.01.19.16.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 16:05:40 -0800 (PST) From: zimoun To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#45893: Hint for package name: too slow! In-Reply-To: <87a6t4hlom.fsf_-_@gnu.org> References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> Date: Wed, 20 Jan 2021 00:59:54 +0100 Message-ID: <86o8hk8olh.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo, > Next up is package names, right? :-) As said I have tried to hint typo about packages for =E2=80=9Cguix show=E2= =80=9D but it is too slow. So, in procrastinating mood, I have tried to investigate a bit. Currently, the cache would be read 2 times, once by =E2=80=99find-packages-by-name=E2=80=99 and then if the returned list is em= pty, again with =E2=80=99fold-available-packages=E2=80=99 to find the closest name. R= ead the cache only once implies a lot of work. However, the first improvement is to speed up =E2=80=99string-distance=E2= =80=99. Well, the naive recursive implementation is well-known to be really slow. Well, one question is: what is the status of Stream in Guile? Without drifting the initial topic, I am interested by the answer because it could be useful for =E2=80=9Cguix git log=E2=80=9D (avoid to traverse all t= he history tree before displaying but traverse when it is required, somehow). Cheers, simon --8<---------------cut here---------------start------------->8--- scheme@(guix-user)>=20 (use-modules (gnu packages) (guix utils)) (define (read-the-cache guess) (map (lambda (name) (identity name)) (fold-available-packages (lambda* (name version result #:key supported? deprecated? #:allow-other-keys) (if (and supported? (not deprecated?)) (cons name result) result)) '()))) (define (compute-distance guess) (map (lambda (name) (string-distance guess name)) (fold-available-packages (lambda* (name version result #:key supported? deprecated? #:allow-other-keys) (if (and supported? (not deprecated?)) (cons name result) result)) '()))) scheme@(guix-user)> ,time (define foo (read-the-cache "macs-mgit")) ;; 3.492591s real time, 4.523108s run time. 1.530055s spent in GC. scheme@(guix-user)> ,time (define foo (read-the-cache "macs-mgit")) ;; 0.125346s real time, 0.123948s run time. 0.000000s spent in GC. scheme@(guix-user)> ,time (define foo (compute-distance "macs-mgit")) ;; 3.813699s real time, 6.051472s run time. 3.256658s spent in GC. scheme@(guix-user)> ,profile (define foo (compute-distance "macs-mgit")) % cumulative self=20=20=20=20=20=20=20=20=20=20=20=20=20 time seconds seconds procedure 44.68 51.86 1.83 guix/memoization.scm:100:0 17.55 0.72 0.72 hash-set! 12.23 0.54 0.50 guix/utils.scm:863:2:mproc 9.04 0.37 0.37 hash-ref 4.26 47.60 0.17 guix/utils.scm:863:2 3.19 0.13 0.13 list? 2.13 0.09 0.09 string->list 1.60 0.07 0.07 min 1.06 0.04 0.04 ice-9/popen.scm:183:0:reap-pipes 1.06 0.04 0.04 length 0.53 0.26 0.02 guix/combinators.scm:37:2:fold2 0.53 0.02 0.02 equal? 0.53 0.02 0.02 gnu/packages.scm:246:32 0.53 0.02 0.02 char=3D? 0.53 0.02 0.02 pointer->string 0.53 0.02 0.02 srfi/srfi-1.scm:951:15 0.00 30583.00 0.00 ice-9/boot-9.scm:220:5:map1 0.00 4.08 0.00 :31:9 0.00 0.15 0.00 :17:0:compute-distance 0.00 0.13 0.00 guix/discovery.scm:177:0:fold-module-public-var= iables 0.00 0.11 0.00 guix/discovery.scm:184:19 0.00 0.09 0.00 gnu/packages.scm:224:21 0.00 0.09 0.00 guix/utils.scm:860:0:string-distance 0.00 0.04 0.00 guix/packages.scm:933:0:supported-package? 0.00 0.04 0.00 srfi/srfi-1.scm:734:0:find-tail 0.00 0.04 0.00 %after-gc-thunk 0.00 0.04 0.00 anon #x227d190 0.00 0.02 0.00 ice-9/boot-9.scm:1673:4:with-exception-handler 0.00 0.02 0.00 guix/discovery.scm:43:0:scheme-files 0.00 0.02 0.00 gnu/packages.scm:237:0:fold-packages 0.00 0.02 0.00 srfi/srfi-1.scm:452:2:fold 0.00 0.02 0.00 guix/discovery.scm:137:8 0.00 0.02 0.00 guix/build/syscalls.scm:993:4 0.00 0.02 0.00 guix/discovery.scm:59:14 0.00 0.02 0.00 guix/discovery.scm:100:0:scheme-modules 0.00 0.02 0.00 guix/discovery.scm:148:0:all-modules 0.00 0.02 0.00 guix/build/syscalls.scm:1014:0:scandir* 0.00 0.02 0.00 srfi/srfi-1.scm:487:0:fold-right --- Sample count: 188 Total time: 4.084680487 seconds (2.659723098 seconds in GC) scheme@(guix-user)> --8<---------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 20 04:58:24 2021 Received: (at 45893) by debbugs.gnu.org; 20 Jan 2021 09:58:25 +0000 Received: from localhost ([127.0.0.1]:52949 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2AFs-0003Ma-KS for submit@debbugs.gnu.org; Wed, 20 Jan 2021 04:58:24 -0500 Received: from mail-wm1-f50.google.com ([209.85.128.50]:54061) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2AFq-0003ML-7O for 45893@debbugs.gnu.org; Wed, 20 Jan 2021 04:58:23 -0500 Received: by mail-wm1-f50.google.com with SMTP id j18so2263522wmi.3 for <45893@debbugs.gnu.org>; Wed, 20 Jan 2021 01:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=PibM+cCAPr2E8aM6E5XRyoc3peBbr7yIvgt9qbG066I=; b=gpygHfLOrfGIr3hRG7x6vGIlSq1BQMNdtA9o8u/ZOqMHkBcpCGYseHocAXmL7FzZPJ sZE3ko0njtaVes1iBRn/guh9LtFY3pjzjQItkwctP3qVlZqixG9Z0uDk4IXaVsGOIBB4 J0WPd8gevfhR/SswtiTH/WZN+thYS0xj2XGZq6Yxb4paPSZ7ZTX3ro8vcuYfbO2+OXN7 lqb229A3kcK3ZM9tb2a7lZnFCQR2Ej/upc1NltlCdbMkyeodk0UiIlQxZRnHgiNPkNZF o14nCU/rX/CsM6BAwFy2SJ5Hg1LS+dnFcdDHjULoEQrNkl3GorDmSRzZo+j7VEsl2ndl oV+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=PibM+cCAPr2E8aM6E5XRyoc3peBbr7yIvgt9qbG066I=; b=sqkk6TO2fXrYYjVbm7jxf1ddRvqjeUQPr8GLbUL32EL32QW2LM2mcz0/aRPsP+iUjp E7RLFcsHN4uw3d1loqcgxMBVfGMbur+j886y/XxomAy5MzgAyUN5dzxZRs2M9rKqa+kC KF1gjCNv/JI875aFGhur5eD2dTgixlLBY3rnNXnZ7++TourGk27nMg2tpeX3FOCuC3Tx st6nYE8CkqHmHIOQ8ITLQIdB2cpLySmYZUWBdWuhfDxb3XLZSW3gvbNlJzMBgiki+44X /gKLlmwgecDQef51X0dZyCjRJkSDYKZL5fqhHqay5M6frD4y3WYAx4Jhet8F51xmFEbO Hi9Q== X-Gm-Message-State: AOAM533VafAonongdBTYnp74ydJlPuWv2LOyAL9Yf3LoUn4xJoojg9ak Sf28k24RtYKKzmEeBu3AZeDbOxp8Nq8= X-Google-Smtp-Source: ABdhPJx3Lkz5lsaN5l4wtAka32U9cf6BN1hWh6m3qKZ8nv8Dn4kwVFC/EkxZ8ehZ5NWHXz7l+nleBw== X-Received: by 2002:a1c:a406:: with SMTP id n6mr3550276wme.53.1611136695876; Wed, 20 Jan 2021 01:58:15 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id b132sm2990582wmh.21.2021.01.20.01.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 01:58:15 -0800 (PST) From: zimoun To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#45893: Hint for package name: full matrix iteration In-Reply-To: <86o8hk8olh.fsf@gmail.com> References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> <86o8hk8olh.fsf@gmail.com> Date: Wed, 20 Jan 2021 10:49:47 +0100 Message-ID: <86ft2w7xac.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, On Wed, 20 Jan 2021 at 00:59, zimoun wrote: > However, the first improvement is to speed up =E2=80=99string-distance=E2= =80=99. Well, > the naive recursive implementation is well-known to be really slow. For the interested reader, the patch implements the naive recursion version. And just to compare, I have quickly compared to the iterative with full matrix. See [1]. Roughly speaking, it is a factor of 5x. --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,time (define x (read-the-cache "macs-mgit")) ;; 3.425513s real time, 4.524607s run time. 1.619604s spent in GC. scheme@(guix-user)> ,time (define x (compute-distance2 "macs-mgit")) ;; 0.870167s real time, 1.056089s run time. 0.271307s spent in GC. scheme@(guix-user)> ,time (define x (compute-distance "macs-mgit")) ;; 3.637917s real time, 5.601863s run time. 2.847500s spent in GC. --8<---------------cut here---------------end--------------->8--- The naive recursion version seems fast enough for options and commands =E2=80=93=E2=80=93 because there are few. The key advantage of recursion i= mplementation is the readibility, IMHO. Compare with the iteration with full matrix below. I am in favor to merge this naive recursion version for now. And postpone improvements. Because to be competitive for package hints, instead of plain =E2=80=9Cedit distance=E2=80=9C which scales poorly, there= is 2 directions: - implement =E2=80=99string-distance=E2=80=99 at the C level (in the stand= ard library?) - pre-process the package names at package cache build time; with suffix tree or n-gram or =E2=80=93=E2=80=93 in the scope of = =E2=80=9Cguix search=E2=80=9D improvements. Both are piece of works and I am not convinced the package name hint is worth. =20 Cheers, simon 1: --8<---------------cut here---------------start------------->8--- (define (edit-distance s1 s2) (let* ((as (string->list s1)) (bs (string->list s2)) (s (list->vector as)) (t (list->vector bs)) (m (length as)) (n (length bs)) (d (make-typed-array 'u32 0 (1+ m) (1+ n)))) (do ((i 1 (1+ i))) ((> i m)) (array-set! d i i 0)) (do ((j 1 (1+ j))) ((> j n)) (array-set! d j 0 j)) (do ((j 1 (1+ j))) ((> j n)) (do ((i 1 (1+ i))) ((> i m)) (let* ((c1 (vector-ref s (1- i))) (c2 (vector-ref t (1- j))) (cost (if (char=3D? c1 c2) 0 1)) (deletion (1+ (array-ref d (1- i) j))) (insertion (1+ (array-ref d i (1- j)))) (substitution (+ cost (array-ref d (1- i) (1- j)))) (v (min deletion insertion substitution))) (array-set! d v i j)))) (array-ref d m n))) --8<---------------cut here---------------end--------------->8--- From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 26 15:53:47 2021 Received: (at 45893) by debbugs.gnu.org; 26 Jan 2021 20:53:47 +0000 Received: from localhost ([127.0.0.1]:42761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4VLP-0004jW-65 for submit@debbugs.gnu.org; Tue, 26 Jan 2021 15:53:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60534) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4VLN-0004jJ-Sf for 45893@debbugs.gnu.org; Tue, 26 Jan 2021 15:53:46 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60156) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4VLI-0006Pa-Km; Tue, 26 Jan 2021 15:53:40 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42762 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l4VLI-0002AX-5Q; Tue, 26 Jan 2021 15:53:40 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> Date: Tue, 26 Jan 2021 21:53:38 +0100 In-Reply-To: (zimoun's message of "Tue, 19 Jan 2021 19:01:24 +0100") Message-ID: <871re7zagd.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, zimoun skribis: > 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 str= ing, 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_ "")... Yes, but here you=E2=80=99re building an enumeration like: =E2=80=98foo=E2=80=99, =E2=80=98bar=E2=80=99, =E2=80=98baz=E2=80=99 This should be i18n=E2=80=99d, and so it should all be in a single format string. > 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. :-) Oh I see. Perhaps instead of (or in addition to) =E2=80=98string-distance= =E2=80=99, you need something like (string-distance) id 1l4VSB-0004ui-Vk for submit@debbugs.gnu.org; Tue, 26 Jan 2021 16:00:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33734) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4VSB-0004uW-Cu for 45893@debbugs.gnu.org; Tue, 26 Jan 2021 16:00:47 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60301) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4VS1-0000Fh-UE; Tue, 26 Jan 2021 16:00:42 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42840 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l4VS0-00008D-M6; Tue, 26 Jan 2021 16:00:37 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> <86o8hk8olh.fsf@gmail.com> Date: Tue, 26 Jan 2021 22:00:35 +0100 In-Reply-To: <86o8hk8olh.fsf@gmail.com> (zimoun's message of "Wed, 20 Jan 2021 00:59:54 +0100") Message-ID: <87v9bjxvkc.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) zimoun skribis: > Well, one question is: what is the status of Stream in Guile? Without > drifting the initial topic, I am interested by the answer because it > could be useful for =E2=80=9Cguix git log=E2=80=9D (avoid to traverse all= the history > tree before displaying but traverse when it is required, somehow). As discussed on IRC, there=E2=80=99s (srfi srfi-41). > (define (read-the-cache guess) > (map (lambda (name) > (identity name)) > (fold-available-packages > (lambda* (name version result > #:key supported? deprecated? > #:allow-other-keys) > (if (and supported? (not deprecated?)) > (cons name result) > result)) > '()))) Why =E2=80=98map=E2=80=99 here? :-) > scheme@(guix-user)> ,time (define foo (read-the-cache "macs-mgit")) > ;; 3.492591s real time, 4.523108s run time. 1.530055s spent in GC. 3.5s?! I have: --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> ,use(gnu packages) scheme@(guix-user)> ,time (define lst (fold-available-packages (lambda* (name version result #:key supported? deprecated? #:allow-other-keys) (if (and supported? (not deprecated?)) (cons name result) result)) '())) ;;; :2:6: warning: possibly unused local top-level variable `lst' ;; 0.093728s real time, 0.130037s run time. 0.065544s spent in GC. --8<---------------cut here---------------end--------------->8--- I assume you=E2=80=99re using =E2=80=98guix repl=E2=80=99 and the cache is = authoritative, meaning that GUIX_PACKAGE_PATH is unset and there=E2=80=99s no =E2=80=98-L= =E2=80=99 flag, right? > scheme@(guix-user)> ,profile (define foo (compute-distance "macs-mgit")) > % cumulative self=20=20=20=20=20=20=20=20=20=20=20=20=20 > time seconds seconds procedure > 44.68 51.86 1.83 guix/memoization.scm:100:0 > 17.55 0.72 0.72 hash-set! > 12.23 0.54 0.50 guix/utils.scm:863:2:mproc > 9.04 0.37 0.37 hash-ref OK, the naive memoizing implementation is inefficient, now we know. :-) Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 26 16:18:56 2021 Received: (at 45893) by debbugs.gnu.org; 26 Jan 2021 21:18:56 +0000 Received: from localhost ([127.0.0.1]:42784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4Vjk-0005Lb-3e for submit@debbugs.gnu.org; Tue, 26 Jan 2021 16:18:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37086) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4Vji-0005LO-P0 for 45893@debbugs.gnu.org; Tue, 26 Jan 2021 16:18:55 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:32884) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4Vjd-0006NL-IN; Tue, 26 Jan 2021 16:18:49 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43078 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l4Vjd-0001ar-38; Tue, 26 Jan 2021 16:18:49 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. References: <20210115163732.53665-1-zimon.toutoune@gmail.com> <20210119212810.20681-1-zimon.toutoune@gmail.com> Date: Tue, 26 Jan 2021 22:18:47 +0100 In-Reply-To: <20210119212810.20681-1-zimon.toutoune@gmail.com> (zimoun's message of "Tue, 19 Jan 2021 22:28:08 +0100") Message-ID: <87mtwvxuq0.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) zimoun skribis: > +(define (string-distance s1 s2) > + "Compute the Levenshtein distance between two strings." > + ;; Naive implemenation > + (define loop > + (mlambda (as bt) In general, =E2=80=98mlambda=E2=80=99 & co. are nice for prototyping, but f= or local procedures like this, it=E2=80=99s a sledgehammer. So instead, we should probably manage memoization state explicitly, but that often leads to code that=E2=80=99s much less nice. Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 26 16:20:48 2021 Received: (at 45893) by debbugs.gnu.org; 26 Jan 2021 21:20:48 +0000 Received: from localhost ([127.0.0.1]:42788 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4VlY-0005OW-Gt for submit@debbugs.gnu.org; Tue, 26 Jan 2021 16:20:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37408) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4VlV-0005OI-VH for 45893@debbugs.gnu.org; Tue, 26 Jan 2021 16:20:46 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:32921) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4VlQ-0006zT-Qf; Tue, 26 Jan 2021 16:20:40 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43098 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l4VlQ-0001lb-5I; Tue, 26 Jan 2021 16:20:40 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. References: <20210115163732.53665-1-zimon.toutoune@gmail.com> <20210119212810.20681-1-zimon.toutoune@gmail.com> Date: Tue, 26 Jan 2021 22:20:39 +0100 In-Reply-To: <20210119212810.20681-1-zimon.toutoune@gmail.com> (zimoun's message of "Tue, 19 Jan 2021 22:28:08 +0100") Message-ID: <87ft2nxumw.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) And the rest LGTM! So I don=E2=80=99t know, should we try a more efficient-but-still-readable variant right away, or should we first apply these three patches? Thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 26 16:32:22 2021 Received: (at 45893) by debbugs.gnu.org; 26 Jan 2021 21:32:23 +0000 Received: from localhost ([127.0.0.1]:42812 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4Vwk-0005hs-NW for submit@debbugs.gnu.org; Tue, 26 Jan 2021 16:32:22 -0500 Received: from mail-wr1-f45.google.com ([209.85.221.45]:46749) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4Vwi-0005he-7L for 45893@debbugs.gnu.org; Tue, 26 Jan 2021 16:32:20 -0500 Received: by mail-wr1-f45.google.com with SMTP id q7so18007482wre.13 for <45893@debbugs.gnu.org>; Tue, 26 Jan 2021 13:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=orARVvb3UGfcIPgeL0OPOPTi05Q76b6CHuaexTWKQr0=; b=SXwv+yd0+vt09qrRTj4YiGgFFEHAIfg8b+DwIShVNGmLMVQ0DoZAOzi1fklhEAMOjT tou0bByMrvTeTXF31zHRa1huC+xnZmKIR9aNF7B2W0W1lFyxCZmoa4UWjMKoYQUXDpu4 7UYYHTd9NarxQc2l2/iRIjSaX/b7wRKt48/hG5Z7OclV0i2ExMfbpnVXPMlVaFvrfq7+ Kbbf1mHH52egz5gxeI/+kbreVqeroYWax38X+0QU5SjRe2g8FU8xrJkhNRcuVLmlxrsV RxcShTdjIaBxoul3DHLecCCMkH34yV1ysUJ/C8eemPJHwINBwiJYIOVFohVt8OfPipPS 7WoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=orARVvb3UGfcIPgeL0OPOPTi05Q76b6CHuaexTWKQr0=; b=j5pO1EvUeRc7jLMm8Hu72AAVjHhWTKt0/QdM2jwSGkhQnMIZ1IrRGvMBToz2HE0XMD cl3kHDjLpQCxTSxpiNdl6Lb6ljuar77vCl8Ln3fPVK0Q1n3HISH+3+hN4nBpwl8TZNvN h01uBOeMjo2sXsbKAjeCqAs6M8up3Sw5dV4+Ns+fgzWFt1r/FOwJgVlDhkQGrQNILl1+ krWwU7jlKqZdgRtWzp2w8yHsNDEkiWqQSVWnuLkzWIzSbNpeDJ2bfWwrOK5WsJOdjawc qyEHGUWcoZuGzG28eqPIY7MR+h98+eO2Fhg6JDfJNa0B3W8TuAqS2P/aQyD7VK7ic/Qs Uu9A== X-Gm-Message-State: AOAM532NK4/MRTxvR+mUQsV/i9MB8D8T4kd8tI42NcGsLtPtef7ITIoM CXDTT7zVJPxdZRcdXN68oFoX/tRuFJI= X-Google-Smtp-Source: ABdhPJwQHF1mY4mhsV6F7n4VNNvMKD3D4ClRjrrwEtqyEGj4EXsyeVqM7/5kNmyk+qf3V9oRPZ0zUA== X-Received: by 2002:a05:6000:12c8:: with SMTP id l8mr7912560wrx.81.1611696734131; Tue, 26 Jan 2021 13:32:14 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id v1sm4763700wmj.31.2021.01.26.13.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 13:32:13 -0800 (PST) From: zimoun To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#45893] [PATCH 0/2] DRAFT: Hint for options. References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> <871re7zagd.fsf_-_@gnu.org> Date: Tue, 26 Jan 2021 22:27:43 +0100 In-Reply-To: <871re7zagd.fsf_-_@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s?= =?utf-8?Q?=22's?= message of "Tue, 26 Jan 2021 21:53:38 +0100") Message-ID: <86r1m7ie28.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Thanks for the review. On Tue, 26 Jan 2021 at 21:53, Ludovic Court=C3=A8s wrote: >>> > + (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 st= ring, 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_ "")... > > Yes, but here you=E2=80=99re building an enumeration like: > > =E2=80=98foo=E2=80=99, =E2=80=98bar=E2=80=99, =E2=80=98baz=E2=80=99 > > This should be i18n=E2=80=99d, and so it should all be in a single format > string. Are the options translated? If yes, then I understand, else I miss. Anyway, I have removed that since I agree with your practical argument: hint is for typo. Type a faulty option name at the same distance as 2 real option names is not a typo. ;-) Cheers, simon From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 26 16:54:08 2021 Received: (at 45893) by debbugs.gnu.org; 26 Jan 2021 21:54:08 +0000 Received: from localhost ([127.0.0.1]:42838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4WHn-0006D3-NB for submit@debbugs.gnu.org; Tue, 26 Jan 2021 16:54:07 -0500 Received: from mail-wr1-f45.google.com ([209.85.221.45]:44045) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4WHl-0006CZ-VQ for 45893@debbugs.gnu.org; Tue, 26 Jan 2021 16:54:06 -0500 Received: by mail-wr1-f45.google.com with SMTP id d16so17402691wro.11 for <45893@debbugs.gnu.org>; Tue, 26 Jan 2021 13:54:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=gBHc5CrxxHjDbk8kKKLDZpcZAI1nbmlfG7lVMKpoCw4=; b=O1THr48fOvKi4QsDbarmtdXC1ubWYit6YVaHozjkDXv9j0l8HVPzwqUaOgrUALBymt ccdsJjGyjGdhw6JepJ/GRunBt+SNPhsuOIef2POEehzR8QqWu7NwXyfeMCH8bwfTWMwl 1wrl8oTD5Erjp8Vrn3A6sONhF/ijPXoDa/ZCWP84Rsr/+DjBGzZbNh6/Rew59hYP+o8t NFx2AJjmg7OeH2yo1l2uJhARuUywkj6GRyQCbWqPLrFZafAI5EZo/9vA+t4Q55oGrwLF yvNYn4ArrDq2qB/C8vplWG6f2I0oqe9U2dWTdxLp1N9NnzP9kTNFGbC8YxZZC96wj+4R qkAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=gBHc5CrxxHjDbk8kKKLDZpcZAI1nbmlfG7lVMKpoCw4=; b=UZzZXb0mKarEEKotj8tLRAKXAPlZcDLn+S33Mkwabq6eY+9guCqffgtbvLBZ6lNJCt 4dMLNehoO9Q7A+M+WNbGuq/Ue4qOgF24mxnC6WW4miuwMQlY3+eYoB49dCKJhlbMwdR9 bRxRcq3/nwtIWzdy2GNaeVqHLrmwU21Ihhqpxq0k8s/fhkU7uFlao0d+wR0T5d+yPDec pCohLzboUKgNQbiPhk93WWjJ3C3HnBL95MYZo1ePEcNKJpSBTuInDKXsMiDiw+rGvFMX LCLB/1GXc/lHFaXbZoPgcjU5jpIEK+yw9BWlqhqMt0PorPUU9X1KB4u23PVjGictXHWw 35kg== X-Gm-Message-State: AOAM5308Drx6U/SK/nnIznA6zrlNdiY6f8W95imdQ6Jd/W3uW6zFF0dU ucCjGEMistyAxlACbKorfkncYLj1OC4= X-Google-Smtp-Source: ABdhPJye7usgZN0N3tLTHu/WCVivyuv1HTLypQ91vsxPJHn8c6CzHaCAZGsViu5UeWcoK19um9ih/g== X-Received: by 2002:a5d:4a50:: with SMTP id v16mr8197622wrs.241.1611698039901; Tue, 26 Jan 2021 13:53:59 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id c16sm45064wrx.51.2021.01.26.13.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 13:53:59 -0800 (PST) From: zimoun To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#45893] [PATCH 0/2] DRAFT: Hint for options. References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> <86o8hk8olh.fsf@gmail.com> <87v9bjxvkc.fsf_-_@gnu.org> Date: Tue, 26 Jan 2021 22:44:46 +0100 In-Reply-To: <87v9bjxvkc.fsf_-_@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s?= =?utf-8?Q?=22's?= message of "Tue, 26 Jan 2021 22:00:35 +0100") Message-ID: <86o8hbid9t.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, On Tue, 26 Jan 2021 at 22:00, Ludovic Court=C3=A8s wrote: > As discussed on IRC, there=E2=80=99s (srfi srfi-41). I am playing with it. Thanks! :-) >> (define (read-the-cache guess) >> (map (lambda (name) >> (identity name)) >> (fold-available-packages >> (lambda* (name version result >> #:key supported? deprecated? >> #:allow-other-keys) >> (if (and supported? (not deprecated?)) >> (cons name result) >> result)) >> '()))) > > Why =E2=80=98map=E2=80=99 here? :-) Good question! Burn CPU? :-) >> scheme@(guix-user)> ,time (define foo (read-the-cache "macs-mgit")) >> ;; 3.492591s real time, 4.523108s run time. 1.530055s spent in GC. > > 3.5s?! I have: > > scheme@(guix-user)> ,use(gnu packages) > scheme@(guix-user)> ,time (define lst (fold-available-packages > (lambda* (name version result > #:key supported? deprecated? > #:allow-other-keys) > (if (and supported? (not deprecated?)) > (cons name result) > result)) > '())) > ;;; :2:6: warning: possibly unused local top-level variable `lst' > ;; 0.093728s real time, 0.130037s run time. 0.065544s spent in GC. > > I assume you=E2=80=99re using =E2=80=98guix repl=E2=80=99 and the cache i= s authoritative, > meaning that GUIX_PACKAGE_PATH is unset and there=E2=80=99s no =E2=80=98-= L=E2=80=99 flag, > right? Yes. GUIX_PACKAGE_PATH unset and no =E2=80=99-L=E2=80=99 flag. So, it sho= uld be worse otherwise.=20=20 Well, I am surprise by the timing difference. I do not remember on which machine I did: maybe an old desktop with spinning disks at work. >> scheme@(guix-user)> ,profile (define foo (compute-distance "macs-mgit")) >> % cumulative self=20=20=20=20=20=20=20=20=20=20=20=20=20 >> time seconds seconds procedure >> 44.68 51.86 1.83 guix/memoization.scm:100:0 >> 17.55 0.72 0.72 hash-set! >> 12.23 0.54 0.50 guix/utils.scm:863:2:mproc >> 9.04 0.37 0.37 hash-ref > > OK, the naive memoizing implementation is inefficient, now we know. :-) =E2=80=99memoize=E2=80=99 or =E2=80=99mlambda=E2=80=99? Or both? Well, th= e thread is mess up to I do not remember which one had been used. On the other hand, the naive recursive edit distance is well know to be slow and ineffective. Cheers, simon From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 26 17:16:13 2021 Received: (at 45893) by debbugs.gnu.org; 26 Jan 2021 22:16:13 +0000 Received: from localhost ([127.0.0.1]:42884 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4WdB-0006m0-2l for submit@debbugs.gnu.org; Tue, 26 Jan 2021 17:16:13 -0500 Received: from mail-wm1-f52.google.com ([209.85.128.52]:35843) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4Wd9-0006ln-Iv for 45893@debbugs.gnu.org; Tue, 26 Jan 2021 17:16:12 -0500 Received: by mail-wm1-f52.google.com with SMTP id i9so4069642wmq.1 for <45893@debbugs.gnu.org>; Tue, 26 Jan 2021 14:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=QPNAYkLIo90XrbdIYC7MFPpjZs6ElewglJQsOOWBMT4=; b=NV5okcF8cQRPdR03jJxUXNHJeHlL9Nx048o8N1OorZIV8lueWxbydda1Qry2x+/ZTq xsPbh5W1nQKUgvJ++kJK297zwasrTpzLqtjtp+kNfBv17lhTMJ9ELRVrYulJp6pb4XR3 QO3k515q76wwRfoCLrMHW+sXC6nbxolY6Js/ITcZAszU/527svuMLE5Iv6BWILJvCSrd goOl2Z1fTxKre2T2dbZGa4Wx7zTX+aRcrLjf69+0+jHUdHaxD67K3ScwiimO94ApX8YS uSrBiyhMZC8pseH0N0J45gQkYZKM+39hJSOlrU7wSmO25VMDdtEwiSC6sgoNtUp53qPb pNAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=QPNAYkLIo90XrbdIYC7MFPpjZs6ElewglJQsOOWBMT4=; b=jVwrzpgj/4N/g3irXecHbBD9AwX9QTKL8PYbBJw4V2mti84KRbX68A8ZTrIIiQqTNJ 037IIApUnett4oudRS4onBGQmnbChsUAAzLU5PrPImT6PA5GtxxAfhNpMNErxhI2iMQE 1gJwDYSTtj/NJQpeAdOpKW7anldAl8FhMsu9jgdHQOEi8yCvW0l096KPPSzqF+lJAb72 rTK/vzWlzTXHTF7EGt9r9qv3GoW/DqCJh75IcZxW+4BJDFXeBntM4LY2L0uaeJIIR2PW WyKTWNNryw0GA7ErkUyAdTxZC88gf4ZegJoojjsj93aO2Aa52CQJTRRPubSVAj7bWQ6X tCdA== X-Gm-Message-State: AOAM5301suJSYnHnm8Yk5N7nfZFrU5/Af+jCjwSE4C3MLAhvsyAwvqji CXZtlaG9aKQT67oPDX7BeP34SBkJeEg= X-Google-Smtp-Source: ABdhPJzdLkyELtBXQHxDxzl0hptt6NaWC6Jds9To4gjc6QuGKDfQNAzLuuVUfocleUFevTkOYs3kKw== X-Received: by 2002:a05:600c:414b:: with SMTP id h11mr1546827wmm.4.1611699365514; Tue, 26 Jan 2021 14:16:05 -0800 (PST) Received: from lili ([88.126.110.68]) by smtp.gmail.com with ESMTPSA id z4sm148718wrw.38.2021.01.26.14.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 14:16:05 -0800 (PST) From: zimoun To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. In-Reply-To: <87ft2nxumw.fsf_-_@gnu.org> References: <20210115163732.53665-1-zimon.toutoune@gmail.com> <20210119212810.20681-1-zimon.toutoune@gmail.com> <87ft2nxumw.fsf_-_@gnu.org> Date: Tue, 26 Jan 2021 23:05:32 +0100 Message-ID: <86lfcficb7.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo, On Tue, 26 Jan 2021 at 22:20, Ludovic Court=C3=A8s wrote: > And the rest LGTM! > > So I don=E2=80=99t know, should we try a more efficient-but-still-readable > variant right away, or should we first apply these three patches? Well, I have implemented [1] the full matrix version, almost copy/paste from Wikipedia [2]. :-) Ugly, isn=E2=80=99t it! Let merge and improve if required, IMHO. As Arun mentioned in the =C2=ABimproving =E2=80=9Cguix search=E2=80=9D=C2=BB thread, maybe it is wor= th to give a look at the Guile string library. However, there is a missing point not discussed and important: it only works for =E2=80=99parse-command-line=E2=80=99 and not =E2=80=99args-fold*= =E2=80=99. The main reason is: I have not found how to raise the hint for these both functions without code duplication. If there is no technical blocking point, I would like to replace (with care and double-check) all the =E2=80=99args-fold*=E2=80=99 by =E2=80=99par= se-command-line=E2=80=99. An unified CLI entry-point. Well, extend what is done for =E2=80=9Cguix show=E2=80=9D and =E2=80=9Cguix= search=E2=80=9D for all the commands. In one commit. WDYT? 1: 2: Cheers, simon From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 27 17:09:50 2021 Received: (at 45893) by debbugs.gnu.org; 27 Jan 2021 22:09:50 +0000 Received: from localhost ([127.0.0.1]:46328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4t0Y-0006ua-IO for submit@debbugs.gnu.org; Wed, 27 Jan 2021 17:09:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l4t0W-0006uN-Pk for 45893@debbugs.gnu.org; Wed, 27 Jan 2021 17:09:49 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56570) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4t0R-0006FU-L2; Wed, 27 Jan 2021 17:09:43 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=51280 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l4t0R-0002cU-8v; Wed, 27 Jan 2021 17:09:43 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: [bug#45893] [PATCH 0/2] DRAFT: Hint for options. References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> <86o8hk8olh.fsf@gmail.com> <87v9bjxvkc.fsf_-_@gnu.org> <86o8hbid9t.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 8 =?utf-8?Q?Pluvi=C3=B4se?= an 229 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 27 Jan 2021 23:09:41 +0100 In-Reply-To: <86o8hbid9t.fsf@gmail.com> (zimoun's message of "Tue, 26 Jan 2021 22:44:46 +0100") Message-ID: <877dnyuj4q.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45893 Cc: 45893@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, zimoun skribis: >>> scheme@(guix-user)> ,profile (define foo (compute-distance "macs-mgit")) >>> % cumulative self=20=20=20=20=20=20=20=20=20=20=20=20=20 >>> time seconds seconds procedure >>> 44.68 51.86 1.83 guix/memoization.scm:100:0 >>> 17.55 0.72 0.72 hash-set! >>> 12.23 0.54 0.50 guix/utils.scm:863:2:mproc >>> 9.04 0.37 0.37 hash-ref >> >> OK, the naive memoizing implementation is inefficient, now we know. :-) > > =E2=80=99memoize=E2=80=99 or =E2=80=99mlambda=E2=80=99? Or both? Both. > Well, the thread is mess up to I do not remember which one had been > used. > > On the other hand, the naive recursive edit distance is well know to be > slow and ineffective. Yeah. Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 03 06:29:09 2021 Received: (at 45893-done) by debbugs.gnu.org; 3 Feb 2021 11:29:09 +0000 Received: from localhost ([127.0.0.1]:36985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7GLN-0000A8-IY for submit@debbugs.gnu.org; Wed, 03 Feb 2021 06:29:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37140) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7GLL-00009j-Ct for 45893-done@debbugs.gnu.org; Wed, 03 Feb 2021 06:29:08 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:39665) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7GLA-00034k-RT; Wed, 03 Feb 2021 06:28:59 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=57884 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1l7GL1-0006cN-23; Wed, 03 Feb 2021 06:28:49 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. References: <20210115163732.53665-1-zimon.toutoune@gmail.com> <20210119212810.20681-1-zimon.toutoune@gmail.com> <87ft2nxumw.fsf_-_@gnu.org> <86lfcficb7.fsf@gmail.com> Date: Wed, 03 Feb 2021 12:28:43 +0100 In-Reply-To: <86lfcficb7.fsf@gmail.com> (zimoun's message of "Tue, 26 Jan 2021 23:05:32 +0100") Message-ID: <877dnpbdas.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 45893-done Cc: 45893-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi! zimoun skribis: > Well, I have implemented [1] the full matrix version, almost copy/paste > from Wikipedia [2]. :-) Ugly, isn=E2=80=99t it! Yup! :-) > Let merge and improve if required, IMHO. As Arun mentioned in the > =C2=ABimproving =E2=80=9Cguix search=E2=80=9D=C2=BB thread, maybe it is w= orth to give a look at > the Guile string library. I went ahead and applied the three patches. I took the liberty to make two changes: 1. Changed =E2=80=9CDo you mean=E2=80=9D to =E2=80=9CDid you mean=E2=80= =9D; 2. Display hints after errors, as is done elsewhere. It=E2=80=99s really pleasant! (I thought: when one types =E2=80=9Cguix clone=E2=80=9D, should we suggest = =E2=80=9Cgit clone=E2=80=9D? :-)) Thanks! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 03 07:15:28 2021 Received: (at 45893-done) by debbugs.gnu.org; 3 Feb 2021 12:15:28 +0000 Received: from localhost ([127.0.0.1]:37190 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7H4C-0001iW-3o for submit@debbugs.gnu.org; Wed, 03 Feb 2021 07:15:28 -0500 Received: from mail-qk1-f177.google.com ([209.85.222.177]:34006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7H4B-0001iF-24 for 45893-done@debbugs.gnu.org; Wed, 03 Feb 2021 07:15:27 -0500 Received: by mail-qk1-f177.google.com with SMTP id t63so23077012qkc.1 for <45893-done@debbugs.gnu.org>; Wed, 03 Feb 2021 04:15:27 -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=szGVhF9AdI4lA+BqGcfamO5/Mj41chuwpD5Vf4CDyX0=; b=gtzjERyQz3czvWposbSGIMpY/xllHXyMv/xUTG1NXmQZcsMHtFdISzQL3WpscI4v+y ze+LMb75JTkwVtVQe/sjm6/W2fLsFwTwOLoyOqJGPMYGjPm01RBVcEcb843Bk6GWSQX2 DWFyb1ApXBzd/YDZTYjkiHvyKN6eFI/CXLA94ODoxr17W4tP9CI/zl2ky82U3OEVo4lK IfTOz12PWYdY54bXbTT4uXAAh6Hb1iUK9PY1wQjsoFvXEPnkP5mKhyD/yoJCCPPhcwAm u6Mm8JJ5fXxiM2ATBAonRRcZptyVuf/947XZCnaS9aR94DNEI6p8svNxU159y/fHg7nG EtNQ== 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=szGVhF9AdI4lA+BqGcfamO5/Mj41chuwpD5Vf4CDyX0=; b=njzd95d/BhDRwje6BFedL5tMxNYRH0xP2oafGWw4u+x1bg6cmdxNGCq1XXDMSsulRr 7HlKNlud/xJTDVZFWO/Ss3otYw2RsE79szPM5v17HKZOkDpCiI/x84JeyVeireBq1W/E oXEkSxZXDUDSQQTyRuvdyZZtBhaVdFgSoZ2GNmucIC8ce2gGEPAhMDNLVSovZyNs7r6J cqFihkp8Tdpt/zcU3A8WAq1JSmOkngEZtj+myg1UZYighszhy2wbVzk60671LaP1sc0M YcyYjMCVf4vs/fEAMXqLJ87r8lVQDRvnuCtju9tofYQbdTMwqmR5sTJ7/54Yc4orhtyf svJA== X-Gm-Message-State: AOAM531uRt5ZzomIKwu9rdpKkyp4cb9scm70GH11y725pBy8DTRjJQKx ZAy+2tPun+c4BPgWUoUFfwvjl66hwZl77vbcMNw= X-Google-Smtp-Source: ABdhPJzGGAukKYAKCPUnXIdPZ9lrtW1CkS7s+w1RTq6QiXIuN/esZPy8mqHsJaOgEHFb9kqbMVEBusvJsgCScGNhcB4= X-Received: by 2002:a05:620a:913:: with SMTP id v19mr2305721qkv.304.1612354521367; Wed, 03 Feb 2021 04:15:21 -0800 (PST) MIME-Version: 1.0 References: <20210115163732.53665-1-zimon.toutoune@gmail.com> <20210119212810.20681-1-zimon.toutoune@gmail.com> <87ft2nxumw.fsf_-_@gnu.org> <86lfcficb7.fsf@gmail.com> <877dnpbdas.fsf_-_@gnu.org> In-Reply-To: <877dnpbdas.fsf_-_@gnu.org> From: zimoun Date: Wed, 3 Feb 2021 13:15:10 +0100 Message-ID: Subject: Re: bug#45893: [PATCH 0/2] DRAFT: Hint for options. To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 45893-done Cc: 45893-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Ludo, On Wed, 3 Feb 2021 at 12:29, Ludovic Court=C3=A8s wrote: > > Let merge and improve if required, IMHO. As Arun mentioned in the > > =C2=ABimproving =E2=80=9Cguix search=E2=80=9D=C2=BB thread, maybe it is= worth to give a look at > > the Guile string library. > > I went ahead and applied the three patches. I took the liberty to make > two changes: Thanks! > It=E2=80=99s really pleasant! Cool! However, it works for commands using 'parse-command-line' and not 'args-fold*'. For example, one patch of the series replace for "guix show" and "guix search". I would like to replace all the args-fold* by parse-command-line, I think it makes sense. WDYT? > (I thought: when one types =E2=80=9Cguix clone=E2=80=9D, should we sugges= t =E2=80=9Cgit clone=E2=80=9D? :-)) Hehe! Maybe an extension could invoke Git under the hood when the command is not found. ;-) Cheers, simon From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 04 18:08:36 2021 Received: (at submit) by debbugs.gnu.org; 4 Feb 2021 23:08:36 +0000 Received: from localhost ([127.0.0.1]:42464 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7njo-0007ZS-KM for submit@debbugs.gnu.org; Thu, 04 Feb 2021 18:08:36 -0500 Received: from lists.gnu.org ([209.51.188.17]:56720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l7njm-0007ZJ-4d for submit@debbugs.gnu.org; Thu, 04 Feb 2021 18:08:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7njm-0007Sb-0O for bug-guix@gnu.org; Thu, 04 Feb 2021 18:08:34 -0500 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:35236) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7njk-0005gH-CT for bug-guix@gnu.org; Thu, 04 Feb 2021 18:08:33 -0500 Received: by mail-qv1-xf34.google.com with SMTP id l14so2619079qvp.2 for ; Thu, 04 Feb 2021 15:08:32 -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=/W3obYoAEt6JG46ahcW159j/J0NiB0nNijnVtaKIQqY=; b=PlDWeEDGbvhHc5kKN5VDcxTykKnAaL8v1b9UDUkLMovFF7aF8rvraxIRjJ+bQ0R+An pYbwZAeqYPWwTNS9YO2Xwn/RGliiiJxudzRZCYi5+22RRxxoJkYKwKbTq73Bnuoo6vp0 /IcGw7wPt8qt0yI1J0TB7e+pHRqI3JoenmT2RWq8gl/L4wJnDc94cglft5AxsmBq010X w+MQkUYW7rye5gxfhbrmol2wysudIGpsqpKr31uwNPmTI/5KPIDb4Rfr6vWgrEISOTjb gYNjHJhyXKKBt8+9YmDba0FnX4ZM3pnrqlvcRyha7jmkp9NI6uBlT/X5hUTzKnHJyQxX kNJw== 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=/W3obYoAEt6JG46ahcW159j/J0NiB0nNijnVtaKIQqY=; b=BBN7CEHqpdAXRCFxj16U1yKeKdG9rV0YdMhzlGRM83vEWnlsGFWAk/FDdQ+Ws/O59P fEGB73Fyp4aWGVxUXKHLAROOVxQUZovRjxT6J8XvXm1SuLGYNqb+fP8wqj4/b1W9foE9 OlYKh9OcXP5vPfg3m1QJqyDcBAFzAnVDctC4ySWjsk39Tb8+UacVhBW9aapcBNlHCuS7 8PHpLyawSaAeZuAsMUJod1AgphUr1FFyubuxs5iY0XOPanLAaeY09ZRLYSct/cMWu7dx uqxyQHQTBQOOfskvFS4JsoRBUp8VpLKnjunuYTWewiIfD7v1+TiU4MKzVaG8Ey4aT2Zu vzPQ== X-Gm-Message-State: AOAM5325tB0M6UcP6ug1bAKFdAeq+58Tm3v37jbP6+V7s/zRECyDtV7h qqr+2EdP9JkWr7Tx3z3cNDM181acwIU9Fh9/xCXZ3vfEHpQ= X-Google-Smtp-Source: ABdhPJyTq5mRfybtM+kN0ZdGSXtWnXtlHXbquG10aLMmzztFZQkDsW12jlEmInNu/8J6YmP4XpGf5UNRjwxGRMPq19Q= X-Received: by 2002:a0c:bf12:: with SMTP id m18mr1872697qvi.40.1612480111434; Thu, 04 Feb 2021 15:08:31 -0800 (PST) MIME-Version: 1.0 References: <20210115163732.53665-1-zimon.toutoune@gmail.com> <20210119212810.20681-1-zimon.toutoune@gmail.com> <86tuqrbjxr.fsf@gmail.com> In-Reply-To: <86tuqrbjxr.fsf@gmail.com> From: zimoun Date: Fri, 5 Feb 2021 00:08:20 +0100 Message-ID: Subject: Re: Typo helper doesn't always know which command is missing To: Leo Famulari Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=zimon.toutoune@gmail.com; helo=mail-qv1-xf34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Bug Guix X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi, On Thu, 4 Feb 2021 at 22:39, zimoun wrote: > =E2=80=A6but not work for all the options: > > --8<---------------cut here---------------start------------->8--- > $ guix system vm --no-grafts ~/src/guix/guix/doc/os-config-bare-bones.tex= i --substitute-rls=3Dhttps://ci.guix.gnu.org --dr-run --derivation > guix system: error: substitute-rls=3Dhttps://ci.guix.gnu.org: unrecognize= d option > --8<---------------cut here---------------end--------------->8--- Fixed by patch#46308. All the best, simon From unknown Thu Jun 19 14:23:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 05 Mar 2021 12:24:09 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator