GNU bug report logs -
#45893
[PATCH 0/2] DRAFT: Hint for options.
Previous Next
Reported by: zimoun <zimon.toutoune <at> gmail.com>
Date: Fri, 15 Jan 2021 16:38:01 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi,
On Tue, 19 Jan 2021 at 18:38, Ludovic Courtès <ludo <at> gnu.org> wrote:
>
> zimoun <zimon.toutoune <at> gmail.com> 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.
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’t it be more natural to suggest 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’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.
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
This bug report was last modified 4 years and 106 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.