Subject: [bug#45893] [PATCH 0/2] DRAFT: Hint for options.

From: Ludovic Courtès <[email-masked]>
Date: Tue, 19 Jan 2021 18:38:01 +0100

zimoun <[email-masked]> 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 ‘string-closest’ 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’t it be more natural to suggest a
single command rather than several?

Also, it seems to me that there’s always at least one hit, is that
correct?  We should make sure that strings above a certain distance are
ignored, in which case there’s no hint to display.

Thanks!

Next up is package names, right?  :-)

Ludo’.