Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH?] Re: Autocorrect for commands with a hyphen (dash) in the name
On Sun, May 24, 2020 at 10:12 AM Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
>
> > You mean you think we can unify lex.c
> > and zle_tricky.c inside spckword()?
>
> Yes, at the moment spckword() is expecting a sort of slightly tokenised
> here and there string, which isn't a particular great interface.
There's a problem with this to which I don't see an immediate solution:
spckword() modifies the original input string in place, to return the
best guess. In both lex.c and zle_tricky.c, that result string is
then used in later code, which means if it goes in tokenized it ought
to come back out that way as well.
In zle_tricky.c it is actually strcmp()'d against the input string,
even though zle_tricky.c then immediately untokenizes it again to
actually insert it on the command line. You said:
> If the spell check worked,
> the result is just a normal word.
We'll at least have to change spckword() from a void function to one
that returns a status of whether it found a guess, because otherwise
"check worked" is a matter of that strcmp().
lex.c seems to want it tokenized, because it then does something
similar to untokenize() except it also converts Nularg (which
untokenize() skips over). Maybe there are guaranteed not to be any
Nularg at that point.
This is all very messy. Also, confirm that hash tables are stored untokenized?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author