Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Autocorrect for commands with a hyphen (dash) in the name
On Mon, May 18, 2020 at 5:53 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Bart Schaefer wrote on Tue, 19 May 2020 00:38 +00:00:
> > Autocorrect isn't really a spelling checker
>
> I think there may be more to it than that. spckword() expects its first
> argument, *s, to be unmetafied; however, when that function is called
> from the «isset(CORRECT)» codepath, *s is metafied.
Ahh, another side-effect of the decision to metafy hyphens.
So, the following? Or should this also have the equivalent of
if (*w == Tilde || *w == Equals || *w == String)
*x = *w;
like zle_tricky.c?
diff --git a/Src/lex.c b/Src/lex.c
index a541def..615da5a 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1868,8 +1868,12 @@ exalias(void)
hwend();
if (interact && isset(SHINSTDIN) && !strin && incasepat <= 0 &&
tok == STRING && !nocorrect && !(inbufflags & INP_ALIAS) &&
- (isset(CORRECTALL) || (isset(CORRECT) && incmdpos)))
- spckword(&tokstr, 1, incmdpos, 1);
+ (isset(CORRECTALL) || (isset(CORRECT) && incmdpos))) {
+ char *x = dupstring(tokstr);
+ untokenize(x);
+ spckword(&x, 1, incmdpos, 1);
+ tokenize(tokstr = x);
+ }
if (!tokstr) {
zshlextext = tokstrings[tok];
Messages sorted by:
Reverse Date,
Date,
Thread,
Author